-
Notifications
You must be signed in to change notification settings - Fork 1
/
o11y.nix
88 lines (83 loc) · 2.06 KB
/
o11y.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{ config, pkgs, lib, ... }:
let
fromYAML = yaml:
builtins.fromJSON (builtins.readFile (pkgs.runCommand "from-yaml" {
inherit yaml;
allowSubstitutes = false;
preferLocalBuild = true;
} ''
${pkgs.remarshal}/bin/remarshal \
-if yaml \
-i <(echo "$yaml") \
-of json \
-o $out
''));
readYAML = path: fromYAML (builtins.readFile path);
baseconfig = { allowUnfree = true; };
unstable = import <nixpkgs-unstable> { config = baseconfig; };
in {
services.promtail = {
# package = unstable.promtail;
enable = true;
configuration = readYAML ("/etc/promtail/config.yaml");
};
services.prometheus = {
#package = unstable.prometheus;
enable = true;
port = 9001;
extraFlags = [ "--web.route-prefix=/" ];
remoteWrite = [{
url = "https://prometheus-us-central1.grafana.net/api/prom/push";
}];
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
};
smokeping = {
enable = true;
hosts = [
"10.0.0.1"
"1.1.1.1"
"8.8.8.8"
"google.com"
"cloudflare.com"
"reddit.com"
"twitter.com"
"shopify.com"
"amazon.com"
];
};
};
scrapeConfigs = [
{
job_name = "integrations/node_exporter";
scrape_interval = "10s";
static_configs = [{
targets = [
"127.0.0.1:${
toString config.services.prometheus.exporters.node.port
}"
];
}];
}
{
job_name = "integrations/ping";
scrape_interval = "10s";
static_configs = [{
targets = [
"127.0.0.1:${
toString config.services.prometheus.exporters.smokeping.port
}"
];
}];
}
{
job_name = "integrations/envoy";
scrape_interval = "10s";
metrics_path = "/stats/prometheus";
static_configs = [{ targets = [ "127.0.0.1:9901" ]; }];
}
];
};
}