Skip to content

Instantly share code, notes, and snippets.

@commana
Created June 20, 2018 15:34
Show Gist options
  • Save commana/8854e25271fd8b950e3288bf0e51a00d to your computer and use it in GitHub Desktop.
Save commana/8854e25271fd8b950e3288bf0e51a00d to your computer and use it in GitHub Desktop.
arsnova.cards: Prometheus, MongoDB, Meteor
diff --git a/server/main.js b/server/main.js
index 4c6ddc6e..11b1c792 100644
--- a/server/main.js
+++ b/server/main.js
@@ -22,4 +22,15 @@ import "../imports/api/userdata.js";
import "../imports/api/webPushSubscriptions.js";
import "./leitner.js";
+// npm install prom-client
+const promClient = require("prom-client");
+promClient.collectDefaultMetrics();
+
+const register = promClient.register;
+// Listen to incoming HTTP requests (can only be used on the server).
+WebApp.connectHandlers.use('/metrics', (req, res, next) => {
+ res.writeHead(200, {'Content-Type': register.contentType});
+ res.end(register.metrics());
+});
+
WebApp.addHtmlAttributeHook(() => ({lang: 'de', charset: 'utf-8'}));
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'mongodb'
static_configs:
- targets: ['localhost:9001']
- job_name: 'cards'
static_configs:
- targets: ['localhost:3000']
MONGODB_URL=mongodb://127.0.0.1:3001/meteor ./mongodb_exporter-linux-amd64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment