Add HTTP input to Fluent Bit configuration and expose port 8889 for telemetry ingestion

This commit is contained in:
Simon Larsen
2024-12-05 14:43:39 +00:00
parent 38ad431b17
commit 06e7228041
6 changed files with 46 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ export default class TelemetryIngest {
try {
// check header.
debugger;
let oneuptimeToken: string | undefined = req.headers[
"x-oneuptime-token"
] as string | undefined;

View File

@@ -6,5 +6,6 @@ USER root
EXPOSE 24224
EXPOSE 24284
EXPOSE 2020
EXPOSE 8889
CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.yaml"]

28
FluentBit/README.md Normal file
View File

@@ -0,0 +1,28 @@
# Fluentd
This guide will help you test fluent-bit logs with OneUptime.
## Prerequisites
- Filuentd docker container running on your system (essentially this folder should be running).
You can run the container using the command `npm run dev fluent-bit`
- OneUptime account
- OneUptime project
- Telemetry Ingestion Key (Create one from the OneUptime dashboard, Click on More -> Project Settings -> Telemetry Ingestion Key)
## Configuration and Testing
- Please make sure the correct token and url is in the configuration file located at `FluentBut/etc/fluent-bit.yaml`.
- Build the docker image using the command `npm run force-build fluent-bit`
- Run the docker image using the command `npm run dev fluent-bit`
- Send logs to the Fluentd container using the curl command
```bash
curl -X POST -H "Content-Type: application/json" -d '{"log": "This is a test log message"}' http://localhost:8889
```
You should be able to see the logs in the OneUptime dashboard.

View File

@@ -1,14 +1,22 @@
service:
flush: 1
log_level: info
http_server: true
http_listen: 0.0.0.0
http_port: 2020
pipeline:
inputs:
- name: random
- name: http
listen: 0.0.0.0
port: 8889
outputs:
- name: stdout
match: '*'
match: '*'
- name: opentelemetry
match: '*'
host: 'otel-collector'
port: 4318
header:
- x-oneuptime-token aaa670e0-ac15-11ef-9e8b-0bf23dab1c65
- x-oneuptime-service-name fluent-bit

View File

@@ -88,6 +88,7 @@ class OpenTelemetryRequestMiddleware {
}
productType = ProductType.Traces;
} else if (req.url.includes("/otlp/v1/logs")) {
debugger;
if (isProtobuf) {
req.body = LogsData.decode(req.body);
}

View File

@@ -430,6 +430,7 @@ services:
- 24225:24224
- 24285:24284
- 2020:2020
- 8889:8889
extends:
file: ./docker-compose.base.yml
service: fluent-bit