Given an input JSON file derived from channels.nix:
{
"channels": {
"nixos-unstable": {
"job": "nixos/trunk-combined/tested",
"current": true
},
"nixos-unstable-small": {
"job": "nixos/unstable-small/tested",
"current": true
},
"nixpkgs-unstable": {
"job": "nixpkgs/trunk/unstable",
"current": false
}
}
}
Run the exporter (optional flag for configuring address and JSON config paths):
$ ./nixos_channel_exporter
2020/06/12 14:01:10 starting NixOS channel exporter on ":9402"
And the current metrics output. The request time histogram is up next, but I ran out of time on stream today.
The requests are done in parallel and I expect the speed benefits will scale with a larger number of channels configured.
$ time curl -s localhost:9402/metrics | grep channel
# HELP channel_current Reports whether or not a channel is expected to be current.
# TYPE channel_current gauge
channel_current{channel="nixos-unstable"} 1
channel_current{channel="nixos-unstable-small"} 1
channel_current{channel="nixpkgs-unstable"} 0
# HELP channel_request_failures_total Number of channel status requests which have failed
# TYPE channel_request_failures_total counter
channel_request_failures_total 0
# HELP channel_revision Synthetic information metric with labels for the current revision of a channel.
# TYPE channel_revision gauge
channel_revision{channel="nixos-unstable",revision="029a5de08390bb03c3f44230b064fd1850c6658a"} 1
channel_revision{channel="nixos-unstable-small",revision="c60e2bee7c514a422ebf74c766e9e18c936ad845"} 1
channel_revision{channel="nixpkgs-unstable",revision="dcb64ea42e64aaecd8e6fef65cc86245c9666818"} 1
# HELP channel_update_time The UNIX timestamp of when a channel was last updated.
# TYPE channel_update_time gauge
channel_update_time{channel="nixos-unstable"} 1.591531611e+09
channel_update_time{channel="nixos-unstable-small"} 1.591971654e+09
channel_update_time{channel="nixpkgs-unstable"} 1.59155694e+09
go_build_info{checksum="",path="github.com/mdlayher/nixos_channel_exporter",version="(devel)"} 1
real 0m0.706s
user 0m0.009s
sys 0m0.000s