--- title: Collecting Hue metrics with Prometheus in Kubernetes author: Hue Team type: post date: 2019-09-16T18:41:42+00:00 url: /collecting-hue-metrics-with-prometheus-in-kubernetes/ sf_thumbnail_type: - none sf_thumbnail_link_type: - link_to_post sf_detail_type: - none sf_page_title: - 1 sf_page_title_style: - standard sf_no_breadcrumbs: - 1 sf_page_title_bg: - none sf_page_title_text_style: - light sf_background_image_size: - cover sf_social_sharing: - 1 sf_related_articles: - 1 sf_sidebar_config: - left-sidebar sf_left_sidebar: - Sidebar-2 sf_right_sidebar: - Sidebar-1 sf_caption_position: - caption-right ampforwp-amp-on-off: - default categories: - Administration - Version 4.6 --- Hue is getting easy to run with its [Docker][1] container and Kubernetes [Helm package][2]. Hue metrics are useful for checking the load (how many users), slowness (average or percentile times taken by requests)… Those have been available via the [/metrics page][3], but here is how to collect and aggregate this information in Kubernetes. [Prometheus][4] is the metric collecting system heavily used in the Kubernetes world. Here we will leverage the [Microk8s][5] distribution that bundles it. First we install the Prometheus operator via [the add-on][6]:
microk8s.enable prometheusAnd see that the Prometheus operator is running, which powers the Prometheus pods in the monitoring namespace:
kubectl get pods -n monitoring NAME READY STATUS RESTARTS AGE alertmanager-main-0 2/2 Running 268 48d grafana-7789c44cc7-7c4pb 1/1 Running 125 48d kube-state-metrics-78c549dd89-kwmwg 4/4 Running 512 48d node-exporter-zlg4s 2/2 Running 259 48d prometheus-adapter-644b448b48-7t8rt 1/1 Running 131 48d prometheus-k8s-0 3/3 Running 364 47d prometheus-operator-7695b59fb8-k2qm2 1/1 Running 130 48dTo tell Prometheus how to get the metrics, we use a [ServiceMonitor.][7] Those metrics are available on the /metrics page of Hue via the [Django Prometheus][8] module. Note that to expose this URL, Hue needs to have this property turned on:
[desktop] enable_prometheus=trueThen we can check that Prometheus is scraping properly Hue:
And charting them in the Graph tab: