Skip to content

Instantly share code, notes, and snippets.

@grahamc

grahamc/prom.nix Secret

Created November 21, 2019 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamc/fc8286a855ec6d6c34d3e107b58f32b0 to your computer and use it in GitHub Desktop.
Save grahamc/fc8286a855ec6d6c34d3e107b58f32b0 to your computer and use it in GitHub Desktop.
let
pkgs = import <nixpkgs> {};
configFile = pkgs.writeText "prometheus.yml" (builtins.toJSON {
global.scrape_interval = "30s";
scrape_configs = [
{
job_name = "weather-berkshires-ma";
metrics_path = "/weather";
params = {
latitude = [ "42.45" ];
longitude = [ "-73.25" ];
};
scheme = "https";
static_configs = [
{
labels = {};
targets = [ "weather.gsc.io" ];
}
];
}
{
job_name = "weather-nyc-ny";
metrics_path = "/weather";
params = {
latitude = [ "40.75" ];
longitude = [ "-73.98" ];
};
scheme = "https";
static_configs = [
{
labels = {};
targets = [ "weather.gsc.io" ];
}
];
}
];
});
in pkgs.dockerTools.buildLayeredImage {
name = "prometheus";
tag = "latest";
contents = [ pkgs.cacert ];
config.User = "1000";
config.Entrypoint = [ "${pkgs.prometheus}/bin/prometheus" ];
config.Cmd = [
"--storage.tsdb.path=/data"
"--config.file=${configFile}"
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment