]> piware.de Git - learn-metrics.git/commitdiff
Add custom prometheus data source from host
authorMartin Pitt <martin@piware.de>
Fri, 21 May 2021 08:40:32 +0000 (10:40 +0200)
committerMartin Pitt <martin@piware.de>
Fri, 21 May 2021 08:40:32 +0000 (10:40 +0200)
Export http/metrics into prometheus via an intermediate web server in
the pod, and configuring it as an additional source.

You can manually provide metrics by copying http/metrics.template to
http/metrics and edit the numbers while prometheus is running.

.gitignore [new file with mode: 0644]
conf-prometheus/prometheus.yml [new file with mode: 0644]
http/README [new file with mode: 0644]
http/metrics.template [new file with mode: 0644]
learn-metrics.yaml

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..ea404d0
--- /dev/null
@@ -0,0 +1 @@
+http/metrics
diff --git a/conf-prometheus/prometheus.yml b/conf-prometheus/prometheus.yml
new file mode 100644 (file)
index 0000000..592ac7a
--- /dev/null
@@ -0,0 +1,22 @@
+global:
+  scrape_interval: 5s
+  scrape_timeout: 5s
+  evaluation_interval: 15s
+alerting:
+  alertmanagers:
+  - static_configs:
+    - targets: []
+    scheme: http
+    timeout: 10s
+    api_version: v1
+scrape_configs:
+- job_name: 'prometheus'
+  static_configs:
+  - targets: ['localhost:9090']
+
+- job_name: host-http
+  honor_timestamps: true
+  metrics_path: /metrics
+  scheme: http
+  static_configs:
+  - targets: ['localhost:8080']
diff --git a/http/README b/http/README
new file mode 100644 (file)
index 0000000..d1b49ee
--- /dev/null
@@ -0,0 +1,2 @@
+This directory will be served by lighttpd in the pod
+Intended for exporting metrics
diff --git a/http/metrics.template b/http/metrics.template
new file mode 100644 (file)
index 0000000..a81fec0
--- /dev/null
@@ -0,0 +1,7 @@
+# HELP thing_count how many things ran
+# TYPE thing_count counter
+thing_count 0
+
+# HELP thing_failures how many things failed
+# TYPE thing_failures counter
+thing_failures 0
index 4d76cf97b920c923b130828fae6ced8917d86604..6966d782784f1423579ec55caef08cdfaeeec434 100644 (file)
@@ -26,9 +26,27 @@ spec:
     - containerPort: 9090
       hostPort: 3001
       protocol: TCP
+    volumeMounts:
+      - name: prometheus-config
+        mountPath: /etc/prometheus/prometheus.yml
+        readOnly: true
+
+  - image: quay.io/bitnami/nginx
+    name: httpd
+    volumeMounts:
+    - name: http
+      mountPath: /app
+      readOnly: true
 
   volumes:
   - hostPath:
       path: ./conf-grafana/datasource.yaml
       type: File
     name: grafana-datasource
+  - hostPath:
+      path: ./conf-prometheus/prometheus.yml
+      type: File
+    name: prometheus-config
+  - hostPath:
+      path: ./http
+    name: http