https://github.com/juntossomosmais/python-fluentd-testing
Test your fluentd configuration leaving manual approach aside
https://github.com/juntossomosmais/python-fluentd-testing
fluentd kubernetes pytest python testing
Last synced: 12 months ago
JSON representation
Test your fluentd configuration leaving manual approach aside
- Host: GitHub
- URL: https://github.com/juntossomosmais/python-fluentd-testing
- Owner: juntossomosmais
- License: mit
- Created: 2020-03-26T22:30:47.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-06-16T17:55:49.000Z (about 1 year ago)
- Last Synced: 2025-06-16T18:50:59.387Z (about 1 year ago)
- Topics: fluentd, kubernetes, pytest, python, testing
- Language: Python
- Homepage:
- Size: 64.5 KB
- Stars: 11
- Watchers: 10
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Fluentd Testing
[](https://github.com/psf/black)

Tired of testing fluentd and wasting lots of your precious time with manual integration tests? How about the lag it causes to your machine?
Now you can easily test your configuration with this project!
## Using remote-interpreter
You can use `remote-interpreter` Docker Compose service as a remote interpreter. It's important that you use `python3` to execute your code.
## Running Fluentd through Docker
You can start a Fluentd daemon by running the following command:
docker-compose run remote-interpreter fluentd -vv -c /fluentd/etc/fluent-dynatrace-1.conf
Then you can enter the container:
docker exec -it python-fluentd-testing_remote-interpreter_run_ee7625b3648c bash
Finally emit what you want to test, let's say:
```shell
echo '{"content": "Emma Brown", "log.source": "cockatiel", "timestamp": "2022-11-21T16:15:40.0000", "severity": "error", "service.name": "power-environment-service", "service.namespace": "dev-762HNW", "custom.attribute": "Fine artist", "audit.action": "GB", "audit.identity": "AHJX83322418325012", "audit.result": "Gold", "service.version": "1.0.0", "trace_id": "07edac7f-887d-498f-ab87-ad97d3b875b2"}' | fluent-cat -p 24230 jsm.testing
```
## Run all the tests
Simply execute the following command:
docker-compose up integration-tests
## Run lint evaluation locally
We have a service for this as well:
docker-compose up lint
## Updating pipenv dependencies
If you update Pipfile, you can issue the following command to refresh your lock file:
docker-compose run remote-interpreter pipenv update
## Testing with your K8S
After you test your configuration, you can proceed to apply your setup to your production environment. Now if you are in a phase where you would like to see if your configuration run in your real environment, like K8S, then you need to do a full manual process.
We did in the past and [here](/tests/resources/k8s-lab/README.md) you can see our tutorial.
## Useful links
- [How to test Fluentd config in Ruby](https://knplabs.com/en/blog/how2tips-how-to-test-fluentd-config)