Setting up Prometheus to monitor Ondat
CoreOS has created a Kubernetes Operator for installing Prometheus. The operator uses ServiceMonitor custom resources (CRs) to scrape IP addresses defined in Kubernetes Endpoints. This article is intended to provide a quick guide to monitoring the Ondat metrics endpoint and can be used with our example Grafana dashboard.
Scripted Prometheus Install
There is a install-prometheus.sh
script that will perform the installation of
Prometheus using the Prometheus operator and a ServiceMonitor monitoring
Ondat. If you wish to use it then follow steps 1 and 2 before skipping to
installing
Grafana. If you
do not wish to use the script then go to the Prometheus
Operator
installation.
N.B. The standard installation of Prometheus and Grafana does not have persistent storage enabled. If you wish to use persistent storage then please see the README.md in the Prometheus directory from Step 1.
- Clone the Ondat deploy repository and move into the
prometheus-operator
directorygit clone https://github.com/storageos/deploy.git storageos cd storageos/k8s/examples/prometheus
- Run the
install-prometheus.sh
script../install-prometheus.sh
Install the Prometheus Operator
- Clone the Ondat deploy repository and move into the
prometheus-operator
directorygit clone https://github.com/coreos/prometheus-operator.git prometheus-operator
- Deploy the quick start
bundle.yaml
kubectl create -f prometheus-operator/bundle.yaml
- Verify that the Prometheus operator is running.
kubectl get pods -l apps.kubernetes.io/name=prometheus-operator
Install Prometheus
Now that the Prometheus Operator is installed, a Prometheus CR can be created which the Prometheus operator will act upon to configure a Prometheus StatefulSet.
- Clone the Ondat deploy repo
git clone https://github.com/storageos/deploy.git storageos cd storageos/k8s/examples/prometheus
- If your cluster uses RBAC then create the necessary Cluster role and service
account for Prometheus.
kubectl create -f prometheus-rbac.yaml
- Create a Prometheus CR that defines a Prometheus StatefulSet.
kubectl create -f prometheus-cr.yaml
- Create a ServiceMonitor CR that directs Prometheus to scrape the Endpoints
defined in the
storageos
Endpoints resource. Prometheus will scrape the/metrics
URL of the Endpoints and collect the metrics.kubectl create -f storageos-serviceMonitor.yaml
- In order to view the Prometheus UI in the browser port forward the local
port to the Prometheus pod port.
The Prometheus UI can now be seen in the browser at localhost:9090
kubectl port-forward prometheus-prometheus-storageos-0 9090
- Now that the Prometheus UI is available Ondat metrics can be queried from the Graph page. A complete list of Ondat metrics can be found here
Install Grafana
Grafana is a popular solution for visualising metrics. At the time of writing (30/04/2019) there is no Grafana operator so instead a helm installation is used. If a helm installation will not work then the helm generated manifests can be used.
-
Install Grafana
helm install stable/grafana
-
Grafana can query the Prometheus pod for metrics, through a Service. The Prometheus operator automatically creates a service in any namespace that a Prometheus resource is created in. Setup a Grafana data source that points at the Prometheus service that was created. The URL to use will depend on the namespace that Grafana is installed into.
If the Grafana pod runs in the same namespace as the Prometheus pod then the URL is:
http://prometheus-operated:9090
otherwise it’shttp://prometheus-operated.$NAMESPACE.svc:9090
When creating the data source make sure to set the scrape interval.
-
Once the Prometheus data source has been created have a look at the example Ondat dashboard for ideas about how to monitor your cluster.