sitespeedio: cleanup aggregation metrics

This commit is contained in:
Gabriel Fontes
2023-04-28 12:01:27 -03:00
parent 6d9a53300b
commit f484633f2d
2 changed files with 45 additions and 31 deletions
+39 -14
View File
@@ -1,22 +1,46 @@
{ config, ... }:
let
mkStatic = job_name: targets: {
inherit job_name;
scheme = "https";
static_configs = [{ inherit targets; }];
metrics_path = "/metrics";
};
in {
{
services = {
prometheus = {
enable = true;
globalConfig = {
# Scrape a bit more frequently
scrape_interval = "30s";
};
scrapeConfigs = [
(mkStatic "hydra" ["hydra.m7.rs"])
(mkStatic "sitespeed" ["sitespeed.m7.rs"])
(mkStatic "nginx" ["alcyone.m7.rs" "celaeno.m7.rs" "merope.m7.rs"])
{
job_name = "hydra";
static_configs = [{
targets = [ "hydra.m7.rs" ];
}];
}
{
job_name = "nginx";
static_configs =[{
targets = [ "alcyone.m7.rs" "celaeno.m7.rs" "merope.m7.rs" ];
}];
}
{
job_name = "sitespeed";
static_configs = [{
targets = [ "sitespeed.m7.rs" ];
}];
metric_relabel_configs = [
# Only keep metrics that are not aggregations or are medians
{
source_labels = [ "aggr_kind" ];
regex = "(median|)";
action = "keep";
}
# Then remove the aggregation label
{
regex = "aggr_kind";
action = "labeldrop";
}
];
}
];
extraFlags = let
prometheus = config.services.prometheus.package;
extraFlags = let prometheus = config.services.prometheus.package;
in [
# Custom consoles
"--web.console.templates=${prometheus}/etc/prometheus/consoles"
@@ -27,7 +51,8 @@ in {
"metrics.m7.rs" = {
forceSSL = true;
enableACME = true;
locations."/".proxyPass = "http://localhost:${toString config.services.prometheus.port}";
locations."/".proxyPass =
"http://localhost:${toString config.services.prometheus.port}";
};
};
};
+6 -17
View File
@@ -18,33 +18,22 @@
prometheus.exporters.graphite = {
enable = true;
extraFlags = [ "--graphite.mapping-strict-match" ]; # Drop non-matched metrics
mappingSettings.mappings = [
# Page summaries
{
match = ''sitespeed_io\.([^.]+)\.([^.]+)\.pageSummary\.([^.]+)\.([^.]+)\.([^.]+)\.([^.]+)\.(.*)'';
match = ''^sitespeed_io\.([^.]+)\.([^.]+)\.pageSummary\.([^.]+)\.([^.]+)\.([^.]+)\.([^.]+)\.(.+?)(?:\.(mean|max|median|min|p90|p99|p10|rsd|mdev|stddev|total|values))?$'';
match_type = "regex";
name = "sitespeedio_$7";
labels = {
sitespeed_profile = "$1";
sitespeed_job = "$2";
profile = "$1";
site = "$2";
domain = "$3";
page = "$4";
browser = "$5";
platform = "$6";
};
}
# Site summaries
{
match = ''sitespeed_io\.([^.]+)\.([^.]+)\.summary\.([^.]+)\.([^.]+)\.([^.]+)\.(.*)'';
match_type = "regex";
name = "sitespeedio_$6";
labels = {
sitespeed_profile = "$1";
sitespeed_job = "$2";
domain = "$3";
page = "*";
browser = "$4";
platform = "$5";
# We save this so that we can drop specific aggregate metrics
aggr_kind = "$8";
};
}
];