# 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://support.platform9.com/)
