You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -50,23 +50,26 @@ You can push logs with any Loki compatible agent such as the [Promtail](https://
50
50
51
51
## Sending Python logs to Cockpit
52
52
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
+
53
55
<Messagetype="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
55
58
</Message>
56
59
57
60
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.
@@ -108,7 +111,7 @@ You can push logs with any Loki compatible agent such as the [Promtail](https://
108
111
python3 python_logs.py
109
112
```
110
113
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.
112
115
113
116
If your logs do not display, try changing the time range to match the time at which you ran your Python file.
0 commit comments