# Monitoring Addons

The monitoring addon provides the ability for clients to add monitoring solutions like [Grafana](https://platform9.com/docs/kubernetes/accessing-grafana-on-cluster), [Prometheus](https://platform9.com/docs/kubernetes/configuring-persistent-storage), or [Alertmanager](https://platform9.com/docs/kubernetes/monitoring-overview#about-alertmanager). This ensure that concerns are accurately identified, reasons are exposed and mainly, that repairs are implemented in a timely manner which improves overall product quality. For a full accounting of [monitoring options](https://platform9.com/docs/kubernetes/monitoring-overview) and how to [enable them](https://platform9.com/docs/kubernetes/enabling-monitoring), visit our [monitoring pages](https://platform9.com/docs/kubernetes/monitoring-dashboard).

## YAML Specifications

{% tabs %}
{% tab title="YAML" %}

```yaml
apiVersion: sunpike.platform9.com/v1alpha2
kind: ClusterAddon
metadata:
  labels:
    sunpike.pf9.io/cluster: '<clsuuid>'
    type: monitoring
  name: <clsuuid>-monitoring
  namespace: default
spec:
  clusterID: '<clsuuid>'
  override:
    params:
    # storageClassName and pvcSize are optional params, if storage backend 
    # is not configured the prometheus pod will remain in Pending state
    - name: storageClassName  
      value: default
    - name: pvcSize
      value: "1Gi"
    - name: retentionTime
      value: "7d"
  type: monitoring
  version: 0.46.0
  watch: true
```

{% endtab %}
{% endtabs %}

The corresponding `Addon` object created on the cluster will look similar to this.

{% tabs %}
{% tab title="YAML" %}

```yaml
apiVersion: agent.pf9.io/v1
kind: Addon
metadata:
  name: <clsuuid>-monitoring
  namespace: pf9-addons
spec:
  clusterID: <clsuuid>
  type: monitoring
  version: 0.46.0
  watch: true
  override:
    params:
    - name: storageClassName
      value: default
    - name: pvcSize
      value: "1Gi"
    - name: retentionTime
      value: "7d"
```

{% endtab %}
{% endtabs %}

## Prometheus YAML

When the `Prometheus` object is deployed by the addon operator, it introduces the following templatized yaml.

{% tabs %}
{% tab title="YAML" %}

```yaml
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: system
  namespace: pf9-monitoring
spec:
  image: {{ .QuayRegistry }}/prometheus/prometheus
  additionalScrapeConfigs:
    key: additional-scrape-config.yaml
    name: scrapeconfig
  alerting:
    alertmanagers:
    - name: sys-alertmanager
      namespace: pf9-monitoring
      port: web
  replicas: 1
  resources:
    requests:
      cpu: 500m
      memory: 512Mi
  retention: {{ .retentionTime }}
  ruleSelector:
    matchLabels:
      prometheus: system
      role: alert-rules
  scrapeInterval: 2m
  serviceAccountName: system-prometheus
{{- if .storageClassName }}  
  storage:
    volumeClaimTemplate:
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: {{ .pvcSize }}
        storageClassName: {{ .storageClassName }}
{{- end }}  
  serviceMonitorSelector:
    matchLabels:
      prometheus: system
      role: service-monitor
```

{% endtab %}
{% endtabs %}

It should be noted that these addons are updated along with the `pf9-kube` version and can be referenced in the [Support Matrix](https://docs.platform9.com/kubernetes/support-matrix) article. For additional assistance, please contact our [support team](https://platform9.zendesk.com/hc/en-us/requests/new?ticket_form_id=360000924873)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.platform9.com/managed-kubernetes/5.9/platform9-managed-add-ons-overview/monitoring-addons.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
