mirror of
https://github.com/zaphar/Heracles.git
synced 2025-07-27 14:29:51 -04:00
Compare commits
6 Commits
79bf02e1ff
...
94b05b1437
Author | SHA1 | Date | |
---|---|---|---|
![]() |
94b05b1437 | ||
![]() |
668015ed17 | ||
![]() |
63b4f810c2 | ||
![]() |
fe162968e5 | ||
847413f4f5 | |||
18eb50fbbd |
@ -8,10 +8,8 @@
|
|||||||
- source: http://heimdall:9001 # Prometheus source uri for this plot
|
- source: http://heimdall:9001 # Prometheus source uri for this plot
|
||||||
query: 'sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))' # The PromQL query for this plot
|
query: 'sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))' # The PromQL query for this plot
|
||||||
meta: # metadata for this plot
|
meta: # metadata for this plot
|
||||||
name_label: instance # Grab a trace name from the query tags
|
name_format: "`${labels.instance}`" # javascript template literal to format the trace name
|
||||||
#d3_tick_format: "~%" # d3 tick format override for this plot's yaxis
|
#d3_tick_format: "~%" # d3 tick format override for this plot's yaxis
|
||||||
#name_prefix: "Prefix" # A prefix for this sublots trace names
|
|
||||||
#name_suffix: "Suffix" # A suffix for this subplots trace names
|
|
||||||
#named_axis: "y" # yaxis name to use for this subplots traces
|
#named_axis: "y" # yaxis name to use for this subplots traces
|
||||||
span: # The span for this range query
|
span: # The span for this range query
|
||||||
end: now # Where the span ends. RFC3339 format with special handling for the now keyword
|
end: now # Where the span ends. RFC3339 format with special handling for the now keyword
|
||||||
@ -32,16 +30,14 @@
|
|||||||
sum by (instance)(irate(node_cpu_seconds_total{mode="system",job="nodestats"}[5m])) / sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))
|
sum by (instance)(irate(node_cpu_seconds_total{mode="system",job="nodestats"}[5m])) / sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))
|
||||||
meta:
|
meta:
|
||||||
d3_tick_format: "~%"
|
d3_tick_format: "~%"
|
||||||
name_label: instance
|
name_format: "`${labels.instance} system`"
|
||||||
name_prefix: "System"
|
|
||||||
named_axis: "y"
|
named_axis: "y"
|
||||||
- source: http://heimdall:9001
|
- source: http://heimdall:9001
|
||||||
query: |
|
query: |
|
||||||
sum by (instance)(irate(node_cpu_seconds_total{mode="user",job="nodestats"}[5m])) / sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))
|
sum by (instance)(irate(node_cpu_seconds_total{mode="user",job="nodestats"}[5m])) / sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))
|
||||||
meta:
|
meta:
|
||||||
d3_tick_format: "~%"
|
d3_tick_format: "~%"
|
||||||
name_label: instance
|
name_format: "`${labels.instance} user`"
|
||||||
name_suffix: "User"
|
|
||||||
named_axis: "y"
|
named_axis: "y"
|
||||||
- title: Node memory
|
- title: Node memory
|
||||||
query_type: Scalar
|
query_type: Scalar
|
||||||
@ -49,4 +45,4 @@
|
|||||||
- source: http://heimdall:9001
|
- source: http://heimdall:9001
|
||||||
query: 'node_memory_MemFree_bytes{job="nodestats"}'
|
query: 'node_memory_MemFree_bytes{job="nodestats"}'
|
||||||
meta:
|
meta:
|
||||||
name_label: instance
|
name_format: "`${labels.instance}`"
|
||||||
|
10
flake.nix
10
flake.nix
@ -83,9 +83,7 @@
|
|||||||
sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))
|
sum by (instance)(irate(node_cpu_seconds_total{job="nodestats"}[5m]))
|
||||||
\'\';
|
\'\';
|
||||||
meta = {
|
meta = {
|
||||||
name_label = "instance";
|
name_function = "''${labels.instance}";
|
||||||
name_prefix = "trace name prefix";
|
|
||||||
name_suffix = "trace name suffix";
|
|
||||||
named_axis = "y";
|
named_axis = "y";
|
||||||
# yaxis formatting for this subplot
|
# yaxis formatting for this subplot
|
||||||
d3_tick_format = "~s";
|
d3_tick_format = "~s";
|
||||||
@ -114,11 +112,9 @@
|
|||||||
|
|
||||||
config = let
|
config = let
|
||||||
cfg = config.services.heracles;
|
cfg = config.services.heracles;
|
||||||
|
cfgFile = pkgs.writeText "heracles.yaml" (builtins.toJSON cfg.settings);
|
||||||
in
|
in
|
||||||
lib.mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
environment.etc."heracles.yaml" = {
|
|
||||||
text = lib.generators.toYAML {} cfg.settings;
|
|
||||||
};
|
|
||||||
systemd.services.heracles = {
|
systemd.services.heracles = {
|
||||||
wantedBy = ["multi-user.target" "default.target"];
|
wantedBy = ["multi-user.target" "default.target"];
|
||||||
wants = ["network.target"];
|
wants = ["network.target"];
|
||||||
@ -126,7 +122,7 @@
|
|||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "30s";
|
RestartSec = "30s";
|
||||||
ExecStart = "${pkgs.heracles}/bin/heracles --listen ${cfg.listen} --config=${config.environment.etc."heracles.yaml".target}";
|
ExecStart = "${pkgs.heracles}/bin/heracles --listen ${cfg.listen} --config=${cfgFile}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -117,9 +117,7 @@ pub struct DataPoint {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct PlotMeta {
|
pub struct PlotMeta {
|
||||||
name_prefix: Option<String>,
|
name_format: Option<String>,
|
||||||
name_suffix: Option<String>,
|
|
||||||
name_label: Option<String>,
|
|
||||||
named_axis: Option<String>,
|
named_axis: Option<String>,
|
||||||
d3_tick_format: Option<String>,
|
d3_tick_format: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -160,19 +160,17 @@ class TimeseriesGraph extends HTMLElement {
|
|||||||
yaxis: yaxis,
|
yaxis: yaxis,
|
||||||
yhoverformat: meta["d3_tick_format"],
|
yhoverformat: meta["d3_tick_format"],
|
||||||
};
|
};
|
||||||
const namePrefix = meta["name_prefix"];
|
|
||||||
const nameSuffix = meta["name_suffix"];
|
|
||||||
const nameLabel = meta["name_label"];
|
|
||||||
var name = "";
|
var name = "";
|
||||||
if (namePrefix) {
|
const formatter = meta.name_format
|
||||||
name = namePrefix + "-";
|
if (formatter) {
|
||||||
};
|
name = eval(formatter);
|
||||||
if (nameLabel && labels[nameLabel]) {
|
} else {
|
||||||
name = name + labels[nameLabel];
|
var names = [];
|
||||||
};
|
for (const value of labels) {
|
||||||
if (nameSuffix) {
|
names.push(value);
|
||||||
name = name + " - " + nameSuffix;
|
}
|
||||||
};
|
name = names.join(" ");
|
||||||
|
}
|
||||||
if (name) { trace.name = name; }
|
if (name) { trace.name = name; }
|
||||||
for (const point of series) {
|
for (const point of series) {
|
||||||
trace.x.push(new Date(point.timestamp * 1000));
|
trace.x.push(new Date(point.timestamp * 1000));
|
||||||
@ -190,17 +188,22 @@ class TimeseriesGraph extends HTMLElement {
|
|||||||
type: "bar",
|
type: "bar",
|
||||||
x: [],
|
x: [],
|
||||||
y: [],
|
y: [],
|
||||||
yaxis: yaxis,
|
|
||||||
yhoverformat: meta["d3_tick_format"],
|
yhoverformat: meta["d3_tick_format"],
|
||||||
};
|
};
|
||||||
let nameLabel = meta["name_label"];
|
const formatter = meta.name_format;
|
||||||
if (nameLabel && labels[nameLabel]) {
|
var name = "";
|
||||||
trace.name = labels[nameLabel];
|
if (formatter) {
|
||||||
};
|
name = eval(formatter);
|
||||||
if (nameLabel && labels[nameLabel]) {
|
} else {
|
||||||
trace.x.push(labels[nameLabel]);
|
var names = [];
|
||||||
};
|
for (const value of labels) {
|
||||||
|
names.push(value);
|
||||||
|
}
|
||||||
|
name = names.join(" ");
|
||||||
|
}
|
||||||
|
if (name) { trace.name = name; }
|
||||||
trace.y.push(series.value);
|
trace.y.push(series.value);
|
||||||
|
trace.x.push(trace.name);
|
||||||
traces.push(trace);
|
traces.push(trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user