mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 16:33:12 +09:00
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:
1 parent
706ffd9ed2
commit
59758f1576
5 files changed
+39
-27
No files matched your search
+13
-4
@@ -133,11 +133,20 @@ Version 2.0.0
|
|||||||
socket_io_transmit_bytes,
|
socket_io_transmit_bytes,
|
||||||
- Removed clusterio_connected_instaces_gauge and added
|
- Removed clusterio_connected_instaces_gauge and added
|
||||||
clusterio_master_connected_clients_count in its place.
|
clusterio_master_connected_clients_count in its place.
|
||||||
- Renamed clusterio_player_count_gauge to clusterio_instance_player_count
|
- Renamed clusterio_player_count_gauge to
|
||||||
- Removed clusterio_UPS_gauge and added clusterio_instance_game_ticks_total in
|
clusterio_statistics_exporter_instance_player_count
|
||||||
its place.
|
- 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_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,
|
- Removed clusterioMod plugin specific config options logItemTransfers,
|
||||||
disableFairItemDistribution useNeuralNetDoleDivider, autosaveInterval, and
|
disableFairItemDistribution useNeuralNetDoleDivider, autosaveInterval, and
|
||||||
disableImportsOfEverythingExceptElectricity from the master config.
|
disableImportsOfEverythingExceptElectricity from the master config.
|
||||||
|
|||||||
@@ -459,21 +459,24 @@ the metric and updating it somewhere in the plugin code. For example:
|
|||||||
const { Counter } = require('lib/prometheus');
|
const { Counter } = require('lib/prometheus');
|
||||||
|
|
||||||
const fooMetric = new Counter(
|
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
|
// Somewhere in the master plugin code
|
||||||
fooMetric.inc();
|
fooMetric.inc();
|
||||||
|
|
||||||
This works for master plugins, and the metric will be automatically
|
This works for master plugins, and the metric will be automatically
|
||||||
available through the /metric HTTP endpoint. For metrics that are
|
available through the /metric HTTP endpoint. It's recommended that
|
||||||
per-instance you must define an `instance_id` label and set it
|
plugin metrics follow `clusterio_<plugin_name>_<metric_name>` as the
|
||||||
accordingly, for example:
|
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 { Counter } = require('lib/prometheus');
|
||||||
|
|
||||||
const barMetric = new Gauge(
|
const barMetric = new Gauge(
|
||||||
'clusterio_bar_metric', "Bar instance level",
|
'clusterio_foo_frobber_bar_metric', "Bar instance level",
|
||||||
{ labels: ['instance_id'] }
|
{ labels: ['instance_id'] }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ const { Gauge } = require('lib/prometheus');
|
|||||||
|
|
||||||
|
|
||||||
const instancePlayerCount = new Gauge(
|
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'] }
|
{ labels: ['instance_id'] }
|
||||||
);
|
);
|
||||||
const instanceGameTicksTotal = new Gauge(
|
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'] }
|
{ labels: ['instance_id'] }
|
||||||
);
|
);
|
||||||
const instanceForceFlowStatistics = new Gauge(
|
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'] },
|
{ labels: ['instance_id', 'force', 'statistic', 'direction', 'name'] },
|
||||||
);
|
);
|
||||||
const instanceGameFlowStatistics = new Gauge(
|
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'] },
|
{ labels: ['instance_id', 'statistic', 'direction', 'name'] },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ const prometheus = require("lib/prometheus");
|
|||||||
|
|
||||||
|
|
||||||
const prometheusNNDoleGauge = new prometheus.Gauge(
|
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",
|
"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"] }
|
{ labels: ["resource"] }
|
||||||
);
|
);
|
||||||
const prometheusDoleFactorGauge = new prometheus.Gauge(
|
const prometheusDoleFactorGauge = new prometheus.Gauge(
|
||||||
"clusterio_dole_factor_gauge",
|
"clusterio_subspace_storage_dole_factor_gauge",
|
||||||
"The current dole division factor for this resource",
|
"The current dole division factor for this resource",
|
||||||
{ labels: ["resource"] }
|
{ labels: ["resource"] }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,25 +10,25 @@ const routes = require("./routes");
|
|||||||
const dole = require("./dole");
|
const dole = require("./dole");
|
||||||
|
|
||||||
|
|
||||||
const prometheusExportGauge = new prometheus.Gauge(
|
const exportCounter = new prometheus.Counter(
|
||||||
"clusterio_export_gauge",
|
"clusterio_subspace_storage_export_total",
|
||||||
"Resources exported by instance",
|
"Resources exported by instance",
|
||||||
{ labels: ["instance_id", "resource"] }
|
{ labels: ["instance_id", "resource"] }
|
||||||
);
|
);
|
||||||
const prometheusImportGauge = new prometheus.Gauge(
|
const importCounter = new prometheus.Counter(
|
||||||
"clusterio_import_gauge",
|
"clusterio_subspace_storage_import_total",
|
||||||
"Resources imported by instance",
|
"Resources imported by instance",
|
||||||
{ labels: ["instance_id", "resource"] }
|
{ 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 {
|
class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||||
async init() {
|
async init() {
|
||||||
this.prometheusMasterInventoryGauge = new prometheus.Gauge(
|
|
||||||
"clusterio_master_inventory_gauge",
|
|
||||||
"Amount of resources stored on master",
|
|
||||||
{ labels: ["resource"] }
|
|
||||||
);
|
|
||||||
|
|
||||||
this.ui = {
|
this.ui = {
|
||||||
sidebar: [
|
sidebar: [
|
||||||
@@ -91,7 +91,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
|||||||
|
|
||||||
for (let item of message.data.items) {
|
for (let item of message.data.items) {
|
||||||
this.items.addItem(item[0], item[1]);
|
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();
|
this.updateStorage();
|
||||||
@@ -152,7 +152,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
|||||||
|
|
||||||
if (itemsRemoved.length) {
|
if (itemsRemoved.length) {
|
||||||
for (let item of itemsRemoved) {
|
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();
|
this.updateStorage();
|
||||||
@@ -171,7 +171,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
|||||||
onMetrics() {
|
onMetrics() {
|
||||||
if (this.items) {
|
if (this.items) {
|
||||||
for (let [key, count] of this.items._items) {
|
for (let [key, count] of this.items._items) {
|
||||||
this.prometheusMasterInventoryGauge.labels(key).set(Number(count) || 0);
|
masterInventoryGauge.labels(key).set(Number(count) || 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user