I'm working with prometheus to scrape k8s service metrics.
I created a service monitor for my service as below :
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: scmpoll-service-monitor-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
app: scmpoll-{{ template "jenkins-exporter.name" . }}
chart: {{ template "jenkins-exporter.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: scmpoll-{{ template "jenkins-exporter.name" . }}
chart: {{ template "jenkins-exporter.chart" . }}
release: {{ .Release.Name }}
endpoints:
- interval: 1440m
targetPort: 9759
path: /metrics
port: http
I set interval: 1440m because I want prometheus to scrape data once a day.
After deploying the chart, the service monitor was added to prometheus targets but with status unknown and scrape duration 0s. The screenshot below:
Also I have the service monitor added to prometheus config:
- job_name: monitoring/scmpoll-service-monitor-my-release/0
honor_timestamps: true
scrape_interval: 1d
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
I can see that scrape-intervel is set to 1d (24h) but the state is unknown in the screenshot above. Do I have to wait for the next 24h and check or does this mean the configuration is wrong?
Test : i made test with scrape 20minutes and it was the same thing : status unknow with no metrics until the 20 minutes passed and status became UP and metrics were scraped.
I'm not working on prometheus-operator chart, it's an independent chart.