fritzbox_exporter to prometheus k3s problem
Closed this issue · 2 comments
Hello there,
have you deployed this nice piece of software to a k3s cluster?
I already have deployed the container to the cluster. That is working:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ... service/fritzbox-metrics ClusterIP 10.43.44.131 <none> 9042/TCP 14m
In the cluster I can access the URL via curl :
curl -s http://10.43.44.131:9042/metrics
That is working.
But now I want to teach prometheus to collect the available data. How do I get the data collected by prometheus?
To complete the issue, here is my deployment.yml
---
apiVersion: v1
kind: Service
metadata:
namespace: monitoring
name: fritzbox-metrics
labels:
app: fritzbox-metrics
spec:
ports:
- port: 9042
protocol: TCP
selector:
app: fritzboxexporter
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: monitoring
name: fritzboxexporter
spec:
selector:
matchLabels:
app: fritzboxexporter
replicas: 1
template:
metadata:
labels:
app: fritzboxexporter
spec:
containers:
- name: fritzboxexporter
image: kehrhardt/fritzbox_exporter
ports:
- containerPort: 9042
env:
- name: USERNAME
value: "MYUSER"
- name: PASSWORD
value: "MYPASSWORD"
- name: GATEWAY_URL
value: "http://192.168.1.1:49000"
I tried a serviceMonitor, but without any results.
Thanks in advance
Michael
I've never run it with k8s.
but if I remember it correctly you normally need to add some annotations to the services you want the prometheus scraper to collect or add it as dedicated target to your scraper config
OK, I got it. Here is a working copy of my deployment.yaml:
---
apiVersion: v1
kind: Service
metadata:
namespace: monitoring
name: fritzbox-metrics
labels:
app: fritzbox-metrics
spec:
selector:
app: fritzboxexporter
ports:
- name: metrics
port: 9100
targetPort: 9042
type: ClusterIP
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
k8s-app: fritzboxexporter
name: fritzboxexporter
namespace: monitoring
spec:
endpoints:
- interval: 30s
port: metrics
namespaceSelector:
matchNames:
- monitoring
selector:
matchLabels:
app: fritzbox-metrics
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: monitoring
name: fritzboxexporter
spec:
selector:
matchLabels:
app: fritzboxexporter
replicas: 1
template:
metadata:
labels:
app: fritzboxexporter
spec:
containers:
- name: fritzboxexporter
image: kehrhardt/fritzbox_exporter
ports:
- containerPort: 9042
env:
- name: USERNAME
value: "MyUsername"
- name: PASSWORD
value: "MySecretPassword"
- name: GATEWAY_URL
value: "http://192.168.1.1:49000"