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

+13 -4
View File
@@ -133,11 +133,20 @@ Version 2.0.0
socket_io_transmit_bytes,
- Removed clusterio_connected_instaces_gauge and added
clusterio_master_connected_clients_count in its place.
- Renamed clusterio_player_count_gauge to clusterio_instance_player_count
- Removed clusterio_UPS_gauge and added clusterio_instance_game_ticks_total in
its place.
- Renamed clusterio_player_count_gauge to
clusterio_statistics_exporter_instance_player_count
- Removed clusterio_UPS_gauge and added
clusterio_statistics_exporter_instance_game_ticks_total in its place.
- Renamed clusterio_endpoint_hit_gauge to clusterio_http_enpoint_hits_total
- Renamed clusterio_statistics_gauge to clusterio_instance_force_flows
- Renamed clusterio_statistics_gauge to
clusterio_statistics_exporter_instance_force_flows
- Renamed clusterio_nn_dole_gauge to clusterio_subspace_storage_nn_dole_gauge.
- Renamed clusterio_dole_factor_gauge to
clusterio_subspace_storage_dole_factor_gauge.
- Renamed clusterio_import_gauge to clusterio_subspace_storage_import_total.
- Renamed clusterio_export_gauge to clusterio_subspace_storage_export_total.
- Renamed clusterio_master_inventory_gauge to
clusterio_subspace_storage_master_inventory.
- Removed clusterioMod plugin specific config options logItemTransfers,
disableFairItemDistribution useNeuralNetDoleDivider, autosaveInterval, and
disableImportsOfEverythingExceptElectricity from the master config.
+8 -5
View File
@@ -459,21 +459,24 @@ the metric and updating it somewhere in the plugin code. For example:
const { Counter } = require('lib/prometheus');
const fooMetric = new Counter(
'clusterio_foo_metric', "Measures the level of foo",
'clusterio_foo_frobber_foo_metric', "Measures the level of foo",
);
// Somewhere in the master plugin code
fooMetric.inc();
This works for master plugins, and the metric will be automatically
available through the /metric HTTP endpoint. For metrics that are
per-instance you must define an `instance_id` label and set it
accordingly, for example:
available through the /metric HTTP endpoint. It's recommended that
plugin metrics follow `clusterio_<plugin_name>_<metric_name>` as the
naming scheme.
For metrics that are per-instance you must define an `instance_id` label and
set it accordingly, for example:
const { Counter } = require('lib/prometheus');
const barMetric = new Gauge(
'clusterio_bar_metric', "Bar instance level",
'clusterio_foo_frobber_bar_metric', "Bar instance level",
{ labels: ['instance_id'] }
);
+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);
}
}
}