Rename plugin Prometheus metrics

Rename Prometheus metrics exported by plugins to follow the
clusterio_<plugin_name>_<metric_name> naming scheme.
This commit is contained in:
Hornwitser committed 2020-04-03 21:14:30 +02:00
1 parent 706ffd9ed2
commit 59758f1576
5 files changed
+39 -27

No files matched your search

+4 -4
View File
@@ -3,19 +3,19 @@ const { Gauge } = require('lib/prometheus');
const instancePlayerCount = new Gauge(
'clusterio_instance_player_count', "Amount of players connected to this cluster",
"clusterio_statistics_exporter_instance_player_count", "Amount of players connected to this cluster",
{ labels: ['instance_id'] }
);
const instanceGameTicksTotal = new Gauge(
'clusterio_instance_game_ticks_total', "Game tick an instance has progressed to",
"clusterio_statistics_exporter_instance_game_ticks_total", "Game tick an instance has progressed to",
{ labels: ['instance_id'] }
);
const instanceForceFlowStatistics = new Gauge(
'clusterio_instance_force_flow_statistics', "Items/fluids/enemies/buildings produced/built/killed by a force",
"clusterio_statistics_exporter_instance_force_flow_statistics", "Items/fluids/enemies/buildings produced/built/killed by a force",
{ labels: ['instance_id', 'force', 'statistic', 'direction', 'name'] },
);
const instanceGameFlowStatistics = new Gauge(
'clusterio_instance_game_flow_statistics', "Pollution produced/consumed in the game",
"clusterio_statistics_exporter_instance_game_flow_statistics", "Pollution produced/consumed in the game",
{ labels: ['instance_id', 'statistic', 'direction', 'name'] },
);
+2 -2
View File
@@ -4,12 +4,12 @@ const prometheus = require("lib/prometheus");
const prometheusNNDoleGauge = new prometheus.Gauge(
"clusterio_nn_dole_gauge",
"clusterio_subspace_storage_nn_dole_gauge",
"Current demand being supplied by Neural Network ; 1 means all demand covered, 0.5 means about half of each supply is covered, 0 means no items are given",
{ labels: ["resource"] }
);
const prometheusDoleFactorGauge = new prometheus.Gauge(
"clusterio_dole_factor_gauge",
"clusterio_subspace_storage_dole_factor_gauge",
"The current dole division factor for this resource",
{ labels: ["resource"] }
);
+12 -12
View File
@@ -10,25 +10,25 @@ const routes = require("./routes");
const dole = require("./dole");
const prometheusExportGauge = new prometheus.Gauge(
"clusterio_export_gauge",
const exportCounter = new prometheus.Counter(
"clusterio_subspace_storage_export_total",
"Resources exported by instance",
{ labels: ["instance_id", "resource"] }
);
const prometheusImportGauge = new prometheus.Gauge(
"clusterio_import_gauge",
const importCounter = new prometheus.Counter(
"clusterio_subspace_storage_import_total",
"Resources imported by instance",
{ labels: ["instance_id", "resource"] }
);
const masterInventoryGauge = new prometheus.Gauge(
"clusterio_subspace_storage_master_inventory",
"Amount of resources stored on master",
{ labels: ["resource"] }
);
class MasterPlugin extends plugin.BaseMasterPlugin {
async init() {
this.prometheusMasterInventoryGauge = new prometheus.Gauge(
"clusterio_master_inventory_gauge",
"Amount of resources stored on master",
{ labels: ["resource"] }
);
this.ui = {
sidebar: [
@@ -91,7 +91,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
for (let item of message.data.items) {
this.items.addItem(item[0], item[1]);
prometheusExportGauge.labels(String(instanceId), item[0]).inc(item[1]);
exportCounter.labels(String(instanceId), item[0]).inc(item[1]);
}
this.updateStorage();
@@ -152,7 +152,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
if (itemsRemoved.length) {
for (let item of itemsRemoved) {
prometheusImportGauge.labels(String(instanceId), item[0]).inc(item[1]);
importCounter.labels(String(instanceId), item[0]).inc(item[1]);
}
this.updateStorage();
@@ -171,7 +171,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
onMetrics() {
if (this.items) {
for (let [key, count] of this.items._items) {
this.prometheusMasterInventoryGauge.labels(key).set(Number(count) || 0);
masterInventoryGauge.labels(key).set(Number(count) || 0);
}
}
}