mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Add metric mapping slave and instance id to name
Add exported metrics that map instance id and slave id to their respective names. This allows getting the instance name of a metric by doing a left join using query of the form 'metric * on(instance_id) group_left(instance_name) clusterio_master_instance_mapping'.
This commit is contained in:
1 parent
71164faa14
commit
450e27e001
2 files changed
+41
-3
No files matched your search
@@ -51,6 +51,8 @@ Version 2.0.0
|
|||||||
- Added stripping of long paths in the Factorio server log.
|
- Added stripping of long paths in the Factorio server log.
|
||||||
- Added option to configure maximum number of commands to send in parallel.
|
- Added option to configure maximum number of commands to send in parallel.
|
||||||
- Added option to auto start instances on slave startup.
|
- Added option to auto start instances on slave startup.
|
||||||
|
- Added metric mapping of slave and instance ids to their names, allowing
|
||||||
|
them to be displayed by name in queries that join with the mapping.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ let debugEvents = new events.EventEmitter();
|
|||||||
let loadedPlugins = {};
|
let loadedPlugins = {};
|
||||||
let devMiddleware;
|
let devMiddleware;
|
||||||
let clusterLogger;
|
let clusterLogger;
|
||||||
|
let db = {
|
||||||
|
instances: new Map(),
|
||||||
|
slaves: new Map(),
|
||||||
|
};
|
||||||
|
|
||||||
// homebrew modules
|
// homebrew modules
|
||||||
const generateSslCert = require("./src/generate_ssl_cert");
|
const generateSslCert = require("./src/generate_ssl_cert");
|
||||||
@@ -106,6 +110,41 @@ function serveWeb(route) {
|
|||||||
app.use(express.static(path.join(__dirname, "static")));
|
app.use(express.static(path.join(__dirname, "static")));
|
||||||
app.use(express.static("static")); // Used for data export files
|
app.use(express.static("static")); // Used for data export files
|
||||||
|
|
||||||
|
const slaveMappingGauge = new libPrometheus.Gauge(
|
||||||
|
"clusterio_master_slave_mapping",
|
||||||
|
"Mapping of Slave ID to name",
|
||||||
|
{
|
||||||
|
labels: ["slave_id", "slave_name"],
|
||||||
|
callback: function() {
|
||||||
|
slaveMappingGauge.clear();
|
||||||
|
for (let [id, slave] of db.slaves) {
|
||||||
|
slaveMappingGauge.labels({
|
||||||
|
slave_id: String(id),
|
||||||
|
slave_name: slave.name,
|
||||||
|
}).set(1);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const instanceMappingGauge = new libPrometheus.Gauge(
|
||||||
|
"clusterio_master_instance_mapping",
|
||||||
|
"Mapping of Instance ID to name and slave",
|
||||||
|
{
|
||||||
|
labels: ["instance_id", "instance_name", "slave_id"],
|
||||||
|
callback: function() {
|
||||||
|
instanceMappingGauge.clear();
|
||||||
|
for (let [id, instance] of db.instances) {
|
||||||
|
instanceMappingGauge.labels({
|
||||||
|
instance_id: String(id),
|
||||||
|
instance_name: String(instance.config.get("instance.name")),
|
||||||
|
slave_id: String(instance.config.get("instance.assigned_slave")),
|
||||||
|
}).set(1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const endpointHitCounter = new libPrometheus.Counter(
|
const endpointHitCounter = new libPrometheus.Counter(
|
||||||
"clusterio_master_http_endpoint_hits_total",
|
"clusterio_master_http_endpoint_hits_total",
|
||||||
"How many requests a particular HTTP endpoint has gotten",
|
"How many requests a particular HTTP endpoint has gotten",
|
||||||
@@ -280,9 +319,6 @@ const masterConnectedClientsCount = new libPrometheus.Gauge(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// set up database
|
|
||||||
const db = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Map from JSON file in the database directory.
|
* Load Map from JSON file in the database directory.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in new issue
Block a user