add json output
parent
be06105f20
commit
522b3bbce2
|
@ -187,7 +187,7 @@ function output(): void
|
||||||
filter();
|
filter();
|
||||||
global $data, $stats, $globalCounter;
|
global $data, $stats, $globalCounter;
|
||||||
$t = time();
|
$t = time();
|
||||||
|
$json = [];
|
||||||
$prom = "";
|
$prom = "";
|
||||||
$prom .=
|
$prom .=
|
||||||
"# service started at : " .
|
"# service started at : " .
|
||||||
|
@ -261,6 +261,11 @@ function output(): void
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$json[] = [
|
||||||
|
"name" => $entry["name"],
|
||||||
|
"labels" => $entry["labels"] ?? [],
|
||||||
|
"value" => $entry["value"],
|
||||||
|
];
|
||||||
$labels = implode(", ", $labels);
|
$labels = implode(", ", $labels);
|
||||||
if ($labels != "") {
|
if ($labels != "") {
|
||||||
$labels = "{" . $labels . "}";
|
$labels = "{" . $labels . "}";
|
||||||
|
@ -269,6 +274,7 @@ function output(): void
|
||||||
$prom .= $entry["name"] . $labels . " " . $entry["value"] . "\n";
|
$prom .= $entry["name"] . $labels . " " . $entry["value"] . "\n";
|
||||||
}
|
}
|
||||||
file_put_contents("/www/metrics/new.prom", $prom);
|
file_put_contents("/www/metrics/new.prom", $prom);
|
||||||
|
file_put_contents("/www/metrics/json", $json);
|
||||||
rename("/www/metrics/new.prom", "/www/metrics/index.prom");
|
rename("/www/metrics/new.prom", "/www/metrics/index.prom");
|
||||||
// return $prom;
|
// return $prom;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue