Last active
March 4, 2025 09:10
-
-
Save christophlehmann/b1bbf2821a876c7f91d8eec3b6788f24 to your computer and use it in GitHub Desktop.
Example: Monitoring external server with Prometheus Operator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First install prometheus-operator: | |
# | |
# helm install coreos/prometheus-operator --name prometheus-operator | |
# | |
apiVersion: monitoring.coreos.com/v1 | |
kind: ServiceMonitor | |
metadata: | |
name: node-exporter | |
# Namespace of prometheus operator | |
namespace: monitoring | |
labels: | |
prometheus: mon | |
spec: | |
namespaceSelector: | |
matchNames: | |
- server-monitoring | |
selector: | |
matchLabels: | |
k8s-app: node-exporter | |
endpoints: | |
- port: metrics | |
interval: 10s | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: name-your-server-com | |
namespace: server | |
labels: | |
k8s-app: node-exporter | |
spec: | |
type: ExternalName | |
externalName: name.your-server.com | |
clusterIP: "" | |
# Maybe not relevant | |
ports: | |
- name: metrics | |
port: 9100 | |
protocol: TCP | |
targetPort: 9100 | |
--- | |
apiVersion: v1 | |
kind: Endpoints | |
metadata: | |
# Name must match service name | |
name: name-your-server-com | |
namespace: server | |
labels: | |
k8s-app: node-exporter | |
subsets: | |
- addresses: | |
- ip: 192.168.99.12 | |
ports: | |
- name: metrics | |
port: 9100 | |
protocol: TCP |
No, you can either use the serviceMonitor
with the Service
and the Endpoint
or add the configuration in the additionalScrapeConfigs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Do we still need a service monitoring to monitor external service after adding this additional scraperConfigs?