|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: How to monitor your Kubernetes Kapsule cluster with Cockpit using Promtail |
| 4 | + description: This page explains how to integrate Kubernetes container logs with Scaleway Cockpit using Promtail |
| 5 | +content: |
| 6 | + h1: How to monitor your Kubernetes Kapsule cluster with Cockpit using Promtail |
| 7 | + paragraph: This page explains how to integrate Kubernetes container logs with Scaleway Cockpit using Promtail |
| 8 | +categories: |
| 9 | + - iot-hub |
| 10 | +tags: kubernetes kapsule kosmos cockpit promtail logs |
| 11 | +dates: |
| 12 | + validation: 2025-01-27 |
| 13 | + posted: 2025-01-17 |
| 14 | +--- |
| 15 | + |
| 16 | +You can now send **data plane** logs from your [Kapsule or Kosmos](https://www.scaleway.com/en/kubernetes) clusters to [Cockpit](https://www.scaleway.com/en/cockpit/), providing centralized, real-time access to application and system logs. Reduce complexity and manual work thanks to this integration, powered by a **Promtail** deployment via [Easy Deploy](/kubernetes/how-to/enable-easy-deploy/). |
| 17 | + |
| 18 | +This feature allows you to: |
| 19 | + |
| 20 | +- **Enhance observability**: View logs from all your Kubernetes containers in one place. |
| 21 | +- **Simplify troubleshooting**: Quickly drill down into specific pods or containers without needing to configure a separate logging stack. |
| 22 | + |
| 23 | +<Message type="important"> |
| 24 | + This feature does incur costs based on the volume of logs ingested. Refer to [Cockpit FAQ](/faq/cockpit/#how-am-i-billed-for-using-cockpit-with-custom-data) for more details and best practices to avoid unexpected bills. |
| 25 | +</Message> |
| 26 | + |
| 27 | +<Macro id="requirements" /> |
| 28 | + |
| 29 | +- A running [Kapsule](/kubernetes/how-to/create-cluster/) or [Kosmos](/kubernetes/how-to/create-kosmos-cluster/) cluster. |
| 30 | +- An API Key with [IAM permissions](/iam/reference-content/permission-sets/) to: |
| 31 | + - edit your cluster `(KubernetesFullAccess` or `KubernetesSystemMastersGroupAccess`) |
| 32 | + - write on Cockpit (`ObservabilityFullAccess`) |
| 33 | +- [A token](/cockpit/how-to/create-token/) with permissions to push to, and query logs from Cockpit |
| 34 | + |
| 35 | +## Architecture and limitations |
| 36 | + |
| 37 | +### Control plane vs. data plane |
| 38 | + |
| 39 | +- **Control plane**: Fully managed by Scaleway. Users can already [monitor control plane components](/kubernetes/how-to/monitor-cluster/) (e.g., `kube-apiserver`, `CCM`, `CSI`) via Cockpit. |
| 40 | +- **Data plane**: Runs in your Scaleway Project (customer-managed instances, `kubelet`, `containerd`, customer Pods, etc.). You have **full access** to the data plane, including the ability to SSH into nodes. |
| 41 | + |
| 42 | +| Feature | Control plane | Data plane | |
| 43 | +|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------| |
| 44 | +| Responsibility | Fully managed by Scaleway | Managed by the customer (runs in your Scaleway Project) | |
| 45 | +| Components | `kube-apiserver`, `CCM`, `CSI`, etc. | `kubelet`, `containerd`, customer Pods, and system components like `kubelet.service`. | |
| 46 | +| Access | Users can monitor components via Cockpit ([see how-to guide](/kubernetes/how-to/monitor-cluster/)) | Full access to data, including SSH into nodes, log management, and custom configurations. | |
| 47 | +| Billing | Included in cluster costs | Billed based on log ingestion volume (see pricing below). | |
| 48 | + |
| 49 | +Because the data plane is entirely under your control, **logs from any components running on these nodes are considered your own data**. Consequently, shipping these logs to Cockpit is billed based on data ingestion. |
| 50 | + |
| 51 | +## How it works |
| 52 | + |
| 53 | +The system leverages **Promtail** (a lightweight log collector) running on your Kapsule or Kosmos cluster. Promtail forwards logs to the Loki endpoint of your Cockpit instance: |
| 54 | + |
| 55 | +1. **Promtail** can collect logs from: |
| 56 | + - **Container stdout/stderr** (pods) |
| 57 | + - **systemd journal** (e.g., `kubelet.service`) |
| 58 | +2. The app automatically creates a custom datasource called `kubernetes-logs` and a Cockpit token with push logs permission. |
| 59 | +3. **Log data** is transmitted to **Cockpit** (Loki). |
| 60 | +4. **Cockpit** stores and indexes these logs. |
| 61 | + |
| 62 | +## Step-by-step: Enabling container logs in Cockpit |
| 63 | + |
| 64 | +You can use Scaleway’s **[Easy Deploy](/kubernetes/how-to/enable-easy-deploy/)** to add a Promtail deployment to your cluster: |
| 65 | + |
| 66 | +1. Log in to the [Scaleway console](https://console.scaleway.com/) and go to your **Kubernetes** cluster. |
| 67 | +2. Navigate to the **Easy Deploy** tab. |
| 68 | +3. Select **Promtail for Cockpit** from the library. |
| 69 | +4. **Deploy** the application. Promtail will install on your cluster with default settings that: |
| 70 | + - Collect container logs for **all namespaces** (by default). |
| 71 | + - Collect systemd journal logs (e.g., `kubelet.service`). |
| 72 | + - Forward logs securely to **Cockpit**. |
| 73 | + <Message type="note"> |
| 74 | + You can edit the default deployment configuration to filter logs by source (under `config.snippets.scrapeConfigs` in the YAML file). For example: |
| 75 | + ```yaml |
| 76 | + cockpit_promtail_scrape_config_pods: "namespace1,namespace2" |
| 77 | + cockpit_promtail_scrape_config_journal: "kubelet.service,kube-proxy.service" |
| 78 | + ``` |
| 79 | + </Message> |
| 80 | +
|
| 81 | +### Example Promtail configuration |
| 82 | +Below is a simplified snippet of the configuration that Easy Deploy generates by default: |
| 83 | +```yaml |
| 84 | +config: |
| 85 | + clients: |
| 86 | + - bearer_token: "{{{ cockpit_bearer_token }}}" # Automatically set by Easy Deploy |
| 87 | + url: "{{{ cockpit_loki_push_url }}}" # Automatically set by Easy Deploy |
| 88 | + |
| 89 | + snippets: |
| 90 | + scrapeConfigs: | |
| 91 | + {{{- cockpit_promtail_scrape_config_pods }}} # Default: log all pods |
| 92 | + {{{- cockpit_promtail_scrape_config_journal }}} # Default: log all system components |
| 93 | +extraVolumeMounts: |
| 94 | + - mountPath: /var/log/journal |
| 95 | + name: journal |
| 96 | + readOnly: true |
| 97 | +extraVolumes: |
| 98 | + - hostPath: |
| 99 | + path: /var/log/journal |
| 100 | + name: journal |
| 101 | +``` |
| 102 | +<Message type="note"> |
| 103 | + Template values like `{{{ cockpit_bearer_token }}}` (Bearer Token) and `{{{ cockpit_loki_push_url }}}` (Loki URL) are automatically set. Avoid modifying these values. |
| 104 | +</Message> |
| 105 | + |
| 106 | +## Visualizing logs in Cockpit |
| 107 | + |
| 108 | +Once Promtail is running: |
| 109 | + |
| 110 | +1. Go to the **Cockpit** section of the Scaleway console, then click **Open dashboards**. |
| 111 | +2. Log into Grafana using your [Cockpit credentials](/cockpit/how-to/retrieve-grafana-credentials/). |
| 112 | +3. In Grafana's menu, go to dashboards and select **Kubernetes Cluster Pod Log**. |
| 113 | +4. **Filter** by: |
| 114 | + - `Datasource` which is automatically created upon deployment, and visible in the Cockpit console |
| 115 | + - `Cluster Name` ( e.g. `my-kapsule-cluster`) |
| 116 | + - `namespace`, `pod`, or `container` labels to isolate specific workloads |
| 117 | + - **Time range** to limit how far back in history you want to query |
| 118 | +5. **Analyze** logs in real-time or historical mode to troubleshoot issues, watch for errors, or track performance. |
| 119 | + |
| 120 | +## Usage and pricing |
| 121 | + |
| 122 | +Sending logs to Cockpit is billed based on the **total volume of logs ingested**. Learn more about how you are billed for using Cockpit with Scaleway data [in the Cockpit FAQ](/faq/cockpit/#how-am-i-billed-for-using-cockpit-with-my-scaleway-data). |
| 123 | + |
| 124 | +Key points include: |
| 125 | + |
| 126 | +- **Logging rate**: The more logs you produce (e.g. high-traffic workloads or verbose logging), the higher the bill. |
| 127 | +- **Filtering**: Limit logs to critical namespaces or system components only. |
| 128 | + |
| 129 | +<Message type="note"> |
| 130 | + You may edit the default configuration of the deployment to adjust the volume of logs to ingest: |
| 131 | + ```yaml |
| 132 | + extraLimitsConfig: | |
| 133 | + readline_rate_enabled: true # rate limiting |
| 134 | + readline_rate: 10000 # log lines / sec |
| 135 | + readline_burst: 10000 # cap for burst lines |
| 136 | + readline_rate_drop: true # drop excess lines |
| 137 | + ``` |
| 138 | + |
| 139 | +</Message> |
| 140 | + |
| 141 | +<Message type="tip"> |
| 142 | + Always monitor the logs ingestion rate in the dedicated dashboards provided in Cockpit to avoid surprises. |
| 143 | +</Message> |
| 144 | + |
| 145 | +## Security considerations |
| 146 | + |
| 147 | +- **Authentication**: The Promtail client uses a Cockpit Bearer Token to authenticate. Keep this token secret; do not store it in publicly accessible repos. |
| 148 | +- **Encryption**: Communication between Promtail and Cockpit (HTTPS) encrypts logs in transit. |
| 149 | +- **Access Control**: Ensure only trusted team members can deploy Easy Deploy applications or modify cluster-level configurations. |
| 150 | + |
| 151 | +## Troubleshooting |
| 152 | + |
| 153 | +- **No logs appearing** in Cockpit: |
| 154 | + - Verify that the Promtail pod is running. |
| 155 | + ```bash |
| 156 | + kubectl get pods -n <promtail-namespace> |
| 157 | + ``` |
| 158 | + - Inspect Promtail logs for errors. |
| 159 | + ```bash |
| 160 | + kubectl logs <promtail-pod-name> -n <promtail-namespace> |
| 161 | + ``` |
| 162 | + |
| 163 | +- **High log ingestion cost**: |
| 164 | + - Review your **deployment configuration** to filter out verbose logs or unneeded namespaces. |
| 165 | + - Check **log ingestion rate** in the dedicated dashboards for unusual spikes. |
| 166 | + |
| 167 | +## Further resources |
| 168 | + |
| 169 | +- [Observability Cockpit Overview](/cockpit/) |
| 170 | +- [Push logs to Cockpit (How-To)](/cockpit/how-to/send-metrics-logs-to-cockpit/) |
| 171 | +- [Send logs from your Kubernetes cluster to your Cockpit (How-To)](/cockpit/how-to/send-log-from-k8s-to-cockpit/) |
| 172 | +- [Send metrics from your Kubernetes cluster to your Cockpit (How-To)](/cockpit/how-to/send-metrics-from-k8s-to-cockpit/) |
| 173 | +- [Promtail Documentation](https://grafana.com/docs/loki/latest/clients/promtail/) |
| 174 | +- [Scaleway Kapsule Documentation](/kubernetes/kapsule/quickstart/) |
| 175 | +- [Scaleway Kosmos Documentation](/kubernetes/kosmos/quickstart/) |
0 commit comments