Skip to content

Commit

Permalink
Add HTTP input to Fluent Bit configuration and expose port 8889 for t…
Browse files Browse the repository at this point in the history
…elemetry ingestion
  • Loading branch information
simlarsen committed Dec 5, 2024
1 parent 38ad431 commit 06e7228
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Common/Server/Middleware/TelemetryIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default class TelemetryIngest {
try {
// check header.

debugger;

let oneuptimeToken: string | undefined = req.headers[
"x-oneuptime-token"
] as string | undefined;
Expand Down
1 change: 1 addition & 0 deletions FluentBit/Dockerfile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 28 additions & 0 deletions FluentBit/README.md
Original file line number Diff line number Diff line change
@@ -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.



18 changes: 13 additions & 5 deletions FluentBit/etc/fluent-bit.yaml
Original file line number Diff line number Diff line change
@@ -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


1 change: 1 addition & 0 deletions OpenTelemetryIngest/API/OTelIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ services:
- 24225:24224
- 24285:24284
- 2020:2020
- 8889:8889
extends:
file: ./docker-compose.base.yml
service: fluent-bit
Expand Down

0 comments on commit 06e7228

Please sign in to comment.