How to enable monitoring (COS)

This guide shows how to integrate Charmed OpenSearch with the Canonical Observability Stack (COS) for metrics, dashboards, alerts, and logs.

The integration workflow depends on the charm variant:

  • On VMs, the opensearch machine charm exposes a single cos-agent endpoint, and a machine grafana-agent charm collects and forwards the telemetry to COS.

  • On Kubernetes, the opensearch-k8s charm exposes native COS endpoints (metrics-endpoint, grafana-dashboard, and logging), and a grafana-agent-k8s charm in the OpenSearch model collects and forwards the telemetry to COS. If COS Lite runs in the same model, OpenSearch can integrate with the COS applications directly instead.

For background on monitoring features, see the Monitoring explanation.

Prerequisites

  • A deployed opensearch-k8s application with TLS configured

  • A deployed cos-lite bundle, either in the same Kubernetes model as opensearch-k8s or in a separate model

Tip

The COS documentation recommends a dedicated model for COS Lite. If you deploy COS Lite in the OpenSearch model instead (juju deploy cos-lite --trust), skip the offer and consume steps below and integrate the applications directly.

Offer COS interfaces

Switch to the COS K8s controller and offer the required interfaces. The easiest way is to deploy COS Lite with the offers overlay, which creates cross-model offers named grafana-dashboards, loki-logging, and prometheus-receive-remote-write:

juju switch <k8s-controller>:<cos-model>
curl -L https://raw.githubusercontent.com/canonical/cos-lite-bundle/main/overlays/offers-overlay.yaml -O
juju deploy cos-lite --trust --overlay ./offers-overlay.yaml

If COS Lite is already deployed without the overlay, offer the interfaces manually:

juju offer grafana:grafana-dashboard grafana-dashboards
juju offer loki:logging loki-logging
juju offer prometheus:receive-remote-write prometheus-receive-remote-write

Consume offers from the OpenSearch model

Switch to the OpenSearch model and consume the COS offers:

juju switch <opensearch-controller>:<opensearch-model>
juju consume <k8s-controller>:admin/<cos-model>.grafana-dashboards
juju consume <k8s-controller>:admin/<cos-model>.loki-logging
juju consume <k8s-controller>:admin/<cos-model>.prometheus-receive-remote-write

Integrate with COS

Deploy grafana-agent in the OpenSearch model:

juju deploy grafana-agent

Integrate it with the consumed COS offers:

juju integrate grafana-agent grafana-dashboards
juju integrate grafana-agent loki-logging
juju integrate grafana-agent prometheus-receive-remote-write

Integrate it with OpenSearch:

juju integrate grafana-agent opensearch:cos-agent

Note

If grafana-agent-k8s is already deployed in this model (for example, while monitoring Charmed OpenSearch Dashboards), skip this step (agent deployment) and the next step (COS offers integration); only add the OpenSearch integrations below.

Deploy grafana-agent-k8s in the OpenSearch model:

juju deploy grafana-agent-k8s --trust

Integrate it with the consumed COS offers:

juju integrate grafana-agent-k8s:grafana-dashboards-provider grafana-dashboards
juju integrate grafana-agent-k8s:logging-consumer loki-logging
juju integrate grafana-agent-k8s:send-remote-write prometheus-receive-remote-write

Integrate it with OpenSearch:

juju integrate opensearch-k8s:metrics-endpoint grafana-agent-k8s:metrics-endpoint
juju integrate opensearch-k8s:grafana-dashboard grafana-agent-k8s:grafana-dashboards-consumer
juju integrate opensearch-k8s:logging grafana-agent-k8s:logging-provider
  • metrics-endpoint lets the agent scrape the OpenSearch metrics endpoint.

  • grafana-dashboard transfers the Charmed OpenSearch dashboard.

  • logging sends the OpenSearch logs.

If COS Lite is deployed in the same model as opensearch-k8s, skip the agent and the offers, and integrate OpenSearch with the COS applications directly:

juju integrate opensearch-k8s:metrics-endpoint prometheus:metrics-endpoint
juju integrate opensearch-k8s:grafana-dashboard grafana:grafana-dashboard
juju integrate opensearch-k8s:logging loki:logging

After integration, Grafana will display the Charmed OpenSearch dashboard and Loki will receive OpenSearch logs.

Large deployments

For multi-application clusters, integrate grafana-agent with each OpenSearch application. The dashboard aggregates data from all connected units.

For multi-application clusters, repeat the three OpenSearch integrations (metrics-endpoint, grafana-dashboard, and logging) for each OpenSearch application. The dashboard aggregates data from all connected units.

Multiple clusters

Multiple deployments can share the same COS instance. The dashboard provides selectors to filter by cluster.

Access the Grafana web interface

Retrieve the Grafana admin password:

juju run grafana/leader get-admin-password --model <k8s-controller>:<cos-model>

For detailed instructions, see Browse dashboards in the COS tutorial.

In Grafana, select the Charmed OpenSearch dashboard. You can filter by Juju model, application, unit, cluster, and node role.

Charmed OpenSearch Grafana dashboard showing cluster health and shard counts

Charmed OpenSearch Grafana dashboard showing system usage and indexing metrics

To inspect OpenSearch logs, open Explore in Grafana, select the Loki data source, filter by juju_application, and run the query:

Grafana Explore showing OpenSearch logs filtered by Juju application

Note

For exploring and visualising your indexed data (as opposed to cluster health metrics), deploy Charmed OpenSearch Dashboards.

Next steps