On the Service Discovery tab, you can view the default ServiceMonitor that is provided by Prometheus Service of Application Real-Time Monitoring Service (ARMS). You can also create a ServiceMonitor to configure collection rules for Prometheus Service. You can create a ServiceMonitor if you want to monitor the business data of applications in a Kubernetes cluster, such as order information.
Manage the default ServiceMonitor
- prometheus.io/path: /metrics
- prometheus.io/port: "9104"
- prometheus.io/scrape: "true"
View the default ServiceMonitor
- Log on to the ARMS console.
- In the left-side navigation pane, click Prometheus Monitoring.
- In the top navigation bar, select the region in which your Kubernetes cluster resides.
- On the Prometheus Monitoring page, click the name of the Kubernetes cluster.
- In the left-side navigation pane, click Settings.
- On the right side of the page, click the Service Discovery tab, and then click the Default Service Discovery tab.
- Click Details in the Actions column to view the YAML file of the default ServiceMonitor.
- Turn on or off the switch in the Actions column to enable or disable the default ServiceMonitor.
Manage custom ServiceMonitors
You can manually create ServiceMonitors to collect metrics based on your configurations. You are charged fees when you use ServiceMonitors to collect metrics.
Create a ServiceMonitor
- On the Service Discovery tab, click the ServiceMonitor tab. Then, click Add ServiceMonitor.
- In the Add ServiceMonitor dialog box, enter the configuration of the ServiceMonitor and click OK. Sample configuration:
apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: # Enter a unique name. name: tomcat-demo # Enter a namespace. namespace: default spec: endpoints: - interval: 30s # Enter the value of the Name field for Port of Prometheus Exporter in the service.yaml file. port: tomcat-monitor # Enter the value of the Path field for Prometheus Exporter. path: /metrics namespaceSelector: any: true # The namespace of the NGINX demo application. selector: matchLabels: # Enter the value of the Label field in the service.yaml file to find the service.yaml file. app: tomcatThe ServiceMonitor appears on the ServiceMonitor tab.
- Turn on or off the switch in the Actions column of a ServiceMonitor to enable or disable the ServiceMonitor. You can also click Disable all to disable all the ServiceMonitors that have been created.
- Click Delete in the Actions column of a ServiceMonitor to delete the ServiceMonitor.