Skip to content

Commit 07ed9ae

Browse files
committed
fix(doc): add more info feedback
1 parent b533469 commit 07ed9ae

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pages/cockpit/how-to/send-metrics-logs-to-cockpit.mdx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags: metrics cockpit logs observability
99
categories:
1010
- observability
1111
dates:
12-
validation: 2024-12-26
12+
validation: 2025-06-18
1313
posted: 2022-10-31
1414
---
1515

@@ -50,23 +50,26 @@ You can push logs with any Loki compatible agent such as the [Promtail](https://
5050

5151
## Sending Python logs to Cockpit
5252

53+
The section below provides you with a Python script that sends test log messages to Cockpit. It is a safe way to ensure that your custom logs setup works before integrating your real application logs.
54+
5355
<Message type="important">
54-
You need custom logs in the `fr-par` region to follow the procedure below. Find out [how to create custom logs](/cockpit/how-to/create-external-data-sources/).
56+
- You need custom logs in the `fr-par` region to follow the procedure below. Find out [how to create custom logs](/cockpit/how-to/create-external-data-sources/).
57+
- You need to have [created](/iam/how-to/create-api-keys/) a Scaleway API key and retrieved your API secret key
5558
</Message>
5659

5760
1. Open a terminal and run `pip install python-logging-loki` or `pip3 install python-logging-loki` if you are using Python 3, to install the [logging_loki](https://pypi.org/project/python-logging-loki/) package to send your Python logs.
58-
2. [Create a token](/cockpit/how-to/create-token/) with the **Push** permission for logs.
59-
3. Create a `python_logs.py` Python file and paste the following code snippet into it. Make sure that you replace `$SCW_SECRET_KEY` with your API secret key and `$COCKPIT_TOKEN_SECRET_KEY` with your Cockpit token's secret key.
61+
2. [Create a Cockpit token](/cockpit/how-to/create-token/) with the **Push** permission for logs.
62+
3. Create a `python_logs.py` Python file and paste the following code snippet into it. Make sure that you replace `$SCW_API_SECRET_KEY` with your API secret key and `$COCKPIT_TOKEN_SECRET_KEY` with your Cockpit token's secret key.
6063

6164
```
6265
import logging
6366
import logging_loki
6467
import time
6568
6669
handler = logging_loki.LokiHandler(
67-
url="https://logs.cockpit.fr-par.scw.cloud/loki/api/v1/push",
70+
url="https://000avb0d-34ae-66hh-643b-f9e0n3k17773.cockpit.fr-par.scw.cloud/loki/api/v1/push",
6871
tags={"job": "logs_from_python"},
69-
auth=("$SCW_SECRET_KEY", "$COCKPIT_TOKEN_SECRET_KEY"),
72+
auth=("$SCW_API_SECRET_KEY", "$COCKPIT_TOKEN_SECRET_KEY"),
7073
version="1",
7174
7275
)
@@ -108,7 +111,7 @@ You can push logs with any Loki compatible agent such as the [Promtail](https://
108111
python3 python_logs.py
109112
```
110113
11. Click the **Home** icon > **Dashboards**. Your **Logs / App** dashboard should display.
111-
12. Click the **Logs / App** dashboard. Your log lines from the Python snippet should appear.
114+
12. Click the **Logs / App** dashboard. You should see 10 log lines labeled `Error message 0` through `Error message 9`, one per second. This confirms that your setup is working.
112115

113116
If your logs do not display, try changing the time range to match the time at which you ran your Python file.
114117

0 commit comments

Comments
 (0)