File tree Expand file tree Collapse file tree 2 files changed +78
-0
lines changed Expand file tree Collapse file tree 2 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 55 ./pyroscope
66 ./folder-size-metrics
77 ./shard-split
8+ ./random-alerts
89 ] ;
910}
Original file line number Diff line number Diff line change 1+ { withSystem , ... } :
2+ {
3+ flake . modules . nixos . random-alerts =
4+ {
5+ pkgs ,
6+ config ,
7+ lib ,
8+ ...
9+ } :
10+ let
11+ cfg = config . services . random-alerts ;
12+ pkg = withSystem pkgs . stdenv . hostPlatform . system ( { config , ... } : config . packages . random-alerts ) ;
13+ in
14+ {
15+ options . services . random-alerts = with lib ; {
16+ enable = mkEnableOption ( lib . mdDoc "Random Alerts" ) ;
17+ args = {
18+ url = mkOption {
19+ type = types . str ;
20+ example = "http://localhost:9093" ;
21+ description = ''Alertmanager URL'' ;
22+ } ;
23+
24+ min-wait-time = mkOption {
25+ type = types . int ;
26+ default = 3600 ;
27+ example = 360 ;
28+ description = ''Minimum wait time before alert in seconds'' ;
29+ } ;
30+
31+ max-wait-time = mkOption {
32+ type = types . int ;
33+ default = 14400 ;
34+ example = 6000 ;
35+ description = ''Maximum wait time before alert in seconds'' ;
36+ } ;
37+
38+ alert-duration = mkOption {
39+ type = types . int ;
40+ default = 3600 ;
41+ example = 360 ;
42+ description = ''Time after alerts ends in seconds'' ;
43+ } ;
44+
45+ log-level = mkOption {
46+ type = types . enum [
47+ "info"
48+ "trace"
49+ "error"
50+ ] ;
51+ default = "info" ;
52+ } ;
53+ } ;
54+ } ;
55+
56+ config =
57+ let
58+ concatMapAttrsStringSep =
59+ sep : f : attrs :
60+ lib . concatStringsSep sep ( lib . attrValues ( lib . mapAttrs f attrs ) ) ;
61+
62+ args = concatMapAttrsStringSep " " ( n : v : "--${ n } =${ toString v } " ) cfg . args ;
63+ in
64+ lib . mkIf cfg . enable {
65+ systemd . services . random-alerts = {
66+ description = "Random Alerts" ;
67+
68+ wantedBy = [ "multi-user.target" ] ;
69+ serviceConfig = {
70+ DynamicUser = lib . mkDefault true ;
71+ Restart = lib . mkDefault "on-failure" ;
72+ ExecStart = "${ lib . getExe pkg } ${ args } " ;
73+ } ;
74+ } ;
75+ } ;
76+ } ;
77+ }
You can’t perform that action at this time.
0 commit comments