Route Activity Log API Events to Logging Service with Fluent Bit
Overview
This tutorial demonstrates how to stream IONOS CLOUD Activity Log data into the IONOS CLOUD Logging Service (powered by Loki) using Fluent Bit. You will build an automated pipeline that uses a Python script to fetch activity events, forwards them as structured JSON, and enables real-time querying in Grafana.
Target audience
This tutorial benefits cloud administrators, DevOps engineers, and security operators who manage IONOS CLOUD contracts and want a centralized visibility into account activity. Readers benefit from basic familiarity with:
Linux administration (
systemd, shell commands, file editing)Python scripting
Log aggregation concepts and Grafana queries
The IONOS CLOUD Console and API authentication
What you will learn
How to create an IONOS CLOUD Logging Pipeline for generic TCP log sources
How to install and configure Fluent Bit on a Linux virtual machine
How to fetch Activity Log events from the IONOS CLOUD API with a Python script
How to parse and forward JSON events to Loki through Fluent Bit
How to query and filter activity events in Grafana using
LogQLHow to troubleshoot common ingestion problems
Before you begin
Ensure you have:
An active IONOS CLOUD account with permission to view contracts and create Logging Pipelines
An IONOS CLOUD API token with read access to the Activity Log API. Generate one from the Token Manager.
A Linux virtual machine (Ubuntu 20.04 or later recommended) with internet access and
sudoprivilegesAccess to a Grafana instance connected to your IONOS CLOUD Logging Service. See the Logging Service documentation for setup details.
Cost considerations
This tutorial creates billable resources, including an IONOS CLOUD Logging Pipeline and a Linux VM that hosts Fluent Bit. Charges incur based on ingested log volume and VM runtime.
Delete the Logging Pipeline and the VM after you finish to avoid ongoing charges. For current rates, see IONOS CLOUD price list (EUR).
Procedure
Architecture
The diagram below shows the data flow from the Activity Log API to Grafana:
The pipeline consists of three components:
A Python fetcher script queries the IONOS CLOUD Activity Log API for every contract and prints each event as raw JSON.
Fluent Bit runs the script periodically through the
execinput plugin, parses the JSON, and forwards events to bothstdout(for debugging) and the IONOS CLOUD Logging Service (for centralized analysis).Grafana queries and filters the stored logs using
LogQL.
Step 1: Create an IONOS CLOUD Logging Pipeline
Follow the Create a Logging Service pipeline guide and, when you configure the log source, use these values:
Source type:
GenericProtocol:
HTTPTag: a unique name such as
activityLog
Important:
Save the authentication key immediately. The Logging Service displays the authentication key only once on pipeline creation.
Store it in a secure location, such as a password manager. Record the HTTPS endpoint shown in the pipeline details to reference it in the Fluent Bit configuration.
Step 2: Install Fluent Bit on the VM
Run the official Fluent Bit installer.
The installer detects the Linux distribution and installs the latest stable release.
Add the IONOS CLOUD API token to the service configuration.
Create a systemd drop-in override so the token survives package upgrades:
Add the following content in the editor that opens, replacing the placeholder with your token:
Save and close. systemd writes the override to /etc/systemd/system/fluent-bit.service.d/override.conf and reloads the unit automatically.
Start and enable the service.
Verify that the service is active (running) before continuing.
Step 3: Install Python prerequisites
Install python3 and the requests library:
Step 4: Create the Python fetcher script
Create the script directory, the persistent state directory, and the fetcher file:
Paste the following code into the file:
Make the script executable:
(Optional) Test the script manually:
The script prints up to three JSON event lines if your contracts contain recent activity.
Step 5: Configure the Fluent Bit JSON parser
Open the parser configuration file:
Verify that the json parser exists. If not, add the following block:
Step 6: Configure the Fluent Bit input and outputs
Edit the main configuration file:
Append the following sections at the bottom of the file:
Replace the placeholders:
<TAG_NAME>: The tag you defined when creating the Logging Pipeline (for example,activityLog). It becomes both the routing match and the URI path.<HTTPS_ENDPOINT>: The HTTPS endpoint host returned by the pipeline (no scheme, no path).<PIPELINE_AUTH_KEY>: The authentication key from pipeline creation. It is sent in theAPIKEYheader on every request.
Remove the stdout output for production
The second [OUTPUT] block writes events to stdout for debugging. Remove it once you confirm that events reach Loki.
Restart Fluent Bit to apply the changes:
Step 7: Test end-to-end ingestion
Run the script manually.
Confirm the script prints JSON lines:
Inspect Fluent Bit output.
Follow the service logs:
JSON entries appear through the stdout output. Wait up to 300 seconds (the Interval_Sec value) or lower the interval temporarily for faster feedback.
Query Loki in Grafana.
In Grafana, open Explore, select the Loki data source, and run:
For example:
Activity events from your contracts appear in the results panel.
Final result
You have built a complete pipeline that pulls IONOS CLOUD Activity Log events into the Logging Service. Fluent Bit runs the Python fetcher every five minutes, parses each JSON event, and forwards it to Loki through a secure TCP endpoint. Grafana queries return live activity data across all your contracts.
Grafana queries
Use these LogQL examples in Grafana Explore to filter activity events.
Filter by username:
Filter by principal.sourceService:
Filter by event type:
Troubleshooting checklist
Symptom
Resolution
Token missing
Verify the systemd drop-in sets IONOS_API_TOKEN. Run sudo systemctl edit fluent-bit, then sudo systemctl restart fluent-bit.
Parser errors
Confirm /etc/fluent-bit/parsers.conf exists and Parsers_File parsers.conf appears in the [SERVICE] section.
Events visible in stdout but not in Loki
Re-check the http output: Host, Port, URI, and the APIKEY header value must match the pipeline.
exec input does not run
Ensure the script is executable (chmod +x) and starts with #!/usr/bin/env python3.
Missed events after a restart
The script stores the last run timestamp in /var/lib/fluent-bit/activity_log_state.json. Delete the file to force a fresh fetch: sudo rm /var/lib/fluent-bit/activity_log_state.json.
Conclusion
You created an automated pipeline that streams IONOS CLOUD Activity Log data into the Logging Service and visualizes it in Grafana. The setup gives your team a single place to audit user actions, detect errors, and investigate provisioning events across all contracts.
Next steps:
Build Grafana dashboards that group events by user, service, or contract.
Configure Grafana alerts on critical event types such as
Error.Review the Logging Service documentation for retention and security options.
Explore the Activity Log API reference to extend the fetcher with additional metadata.
For one-off exports without a streaming pipeline, see Download activity log entries.
Last updated
Was this helpful?