-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from sciclon2/feat-add-prometheus-remote-write
Feature: Prometheus Remote Write Support
- Loading branch information
Showing
42 changed files
with
1,878 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,7 @@ go.sum | |
|
||
# binaries | ||
bin/ | ||
|
||
# Ignore Nginx TLS certificates | ||
**/nginx.key | ||
**/nginx.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
## End-to-End (E2E) Tests | ||
|
||
### Overview | ||
|
||
End-to-End (E2E) tests are essential to validate the overall system behavior by simulating real-world scenarios. In Kafka-Lag-Go, these tests cover the entire pipeline, ensuring that data flows correctly from Kafka to Redis and, finally, to Prometheus for metric collection and visualization. | ||
|
||
### What Does Kafka-Lag-Go Do? | ||
|
||
Kafka-Lag-Go collects data from Kafka, stores relevant information in Redis, and generates metrics that can be either scraped locally or pushed to a central Prometheus instance using Prometheus Remote Write. | ||
|
||
#### Differences Between Local Prometheus Scrape and Prometheus Remote Write | ||
|
||
- **Local Prometheus Scrape (`/metrics` endpoint)**: This method captures a snapshot of the current state of the system's metrics at any given time when Prometheus performs its scheduled scrapes. Metrics are queried directly from the local endpoint, which gives the latest values for the tracked metrics. | ||
|
||
- **Prometheus Remote Write**: In contrast, this approach pushes metrics to a central Prometheus instance at regular intervals. Remote Write allows for scalable and centralized monitoring, where multiple services or distributed instances can send their metrics to a single, central Prometheus server for aggregation. | ||
|
||
### E2E Test Structure | ||
|
||
The E2E tests for Kafka-Lag-Go are housed in the `test/e2e/` directory. This folder contains all necessary components for each E2E test, including configuration files for Docker Compose and Go-based test files. The main script `run.sh` is used to automate the execution of each test, taking the directory of the specific E2E test as an argument. | ||
|
||
Example structure: | ||
|
||
- `test/e2e/run.sh`: Main script to run E2E tests. | ||
- `test/e2e/tests/`: Directory holding individual E2E tests. | ||
- `test/e2e/tests/[test_name]/`: Each test has its own folder with Docker Compose setup and test configurations. | ||
|
||
The tests are run using the `run.sh` script, which ensures that the infrastructure (Kafka, Redis, etc.) is correctly set up before executing the tests. For example: | ||
```bash | ||
$ test/e2e/run.sh test/e2e/tests/prometheus_local -d | ||
``` | ||
|
||
### Automating E2E Tests in GitHub Actions | ||
|
||
In the GitHub Actions workflow, E2E tests are automatically detected and executed in isolated jobs. Each test folder is run in a separate job to ensure proper isolation since different tests may start their own infrastructure. | ||
|
||
When a new folder is added under `test/e2e/tests/`, it will be automatically picked up by the GitHub workflow and executed as part of the CI pipeline. Each test's infrastructure is provisioned via Docker Compose, and the tests are executed using the Go test files located within each folder. | ||
|
||
### Adding a New E2E Test | ||
|
||
To add a new E2E test: | ||
|
||
1. Copy an existing folder inside `test/e2e/tests/` and modify it according to your test's needs. | ||
2. Update the Docker Compose configuration with any necessary components (e.g., Kafka, Redis, Nginx). | ||
3. Write a new E2E test in Go and place it inside the `go_test/` folder. | ||
|
||
You can test the new E2E test locally using the `run.sh` script by pointing it to the test folder: | ||
```bash | ||
$ cp -a test/e2e/tests/prometheus_remote_write_basic_auth test/e2e/tests/my-new-cool-test | ||
$ # make sure the docker compose file has all the needed services | ||
$ # edit your go_test/e2e_test.go | ||
$ # finally run the test locally | ||
$ test/e2e/run.sh test/e2e/tests/my-new-cool-test -d # -d is for debuging | ||
``` | ||
|
||
E2E tests are automatically triggered when you merge to the main branch or create a new release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# How to Contribute | ||
|
||
We welcome contributions to the Kafka Lag Go project, whether it’s reporting an issue, requesting a feature, or contributing code. Here are some guidelines to get you started: | ||
|
||
## 1. Check the Documentation | ||
|
||
Before contributing, take a look at the documentation in the `docs` folder. It includes valuable information such as: | ||
|
||
- [Architecture Design](docs/Architecture.md): An overview of the system's design, which is helpful for understanding the codebase. | ||
- [E2E Tests](docs/e2e-tests.md): Details on how our end-to-end testing framework works. | ||
|
||
Understanding these documents will help you navigate the project and align your contribution with its goals. | ||
|
||
## 2. Reporting an Issue | ||
|
||
If you encounter a bug or have an idea for a new feature, please create an issue in the GitHub repository. When submitting an issue: | ||
|
||
- **For Bugs**: Include as much information as possible, such as: | ||
- Steps to reproduce the issue | ||
- Expected behavior vs. actual behavior | ||
- Relevant logs or screenshots | ||
- Version of the application and environment details | ||
- **Enable Debug Mode**: To gather more information, you can enable the debug mode in your `config.yaml` file by setting the `log_level` under `app` to `debug`. This will provide additional diagnostic logs that can help in troubleshooting. | ||
|
||
|
||
- **For Feature Requests**: Provide a detailed description of the feature you would like to see added. Include any specific use cases or examples to clarify the request. | ||
|
||
## 3. Contributing Code | ||
|
||
If you'd like to contribute directly by fixing a bug or adding a feature, we encourage you to fork the repository and submit a pull request (PR). | ||
|
||
### Steps for Contributing Code: | ||
|
||
1. **Fork the Repository**: | ||
- Fork the repo on GitHub and clone your fork to your local machine. | ||
|
||
2. **Create a Branch**: | ||
- Create a descriptive branch for your changes, for example: | ||
``` | ||
git checkout -b feature/new-awesome-feature | ||
``` | ||
3. **Make Your Changes**: | ||
- Add the necessary code changes to implement the feature or fix the bug. | ||
- Ensure you write the corresponding unit tests for your changes. | ||
- For larger features, add end-to-end (E2E) tests if applicable. | ||
4. **Run Tests**: | ||
- Before submitting your PR, make sure all unit tests and E2E tests pass by running them locally. | ||
- For unit tests: | ||
```bash | ||
go test ./... -v -cover -count=1 | ||
``` | ||
- For E2E tests, follow the instructions in the [E2E Test Documentation](docs/e2e-tests.md). | ||
5. **Submit a Pull Request**: | ||
- Push your changes to your forked repository and submit a pull request to the main repo. | ||
- Provide a clear description of your changes, linking to the relevant issue if it exists. | ||
## 4. Writing Unit and E2E Tests | ||
Every contribution that includes new functionality or changes should also include corresponding tests to ensure the stability of the project. | ||
### Unit Tests | ||
- **Unit tests** should cover the core functionality of the new feature or fix. They should be located in the corresponding package where the change is made. | ||
### End-to-End (E2E) Tests | ||
- **E2E tests** may be necessary if your contribution affects how the system interacts with external services such as Kafka, Redis, or Prometheus. These tests ensure the full integration works as expected. | ||
- Refer to the `test/e2e/` directory for examples of existing E2E tests. | ||
--- | ||
Thank you for your contributions! We look forward to your participation in the Kafka Lag Go project. |
Oops, something went wrong.