feat: update FluentBit and OTelCollector configurations to include service name in headers and adjust logging level

This commit is contained in:
Simon Larsen 2025-04-04 15:24:40 +01:00
parent f4b0548133
commit 367480fff1
No known key found for this signature in database
GPG key ID: 96C5DCA24769DBCA
3 changed files with 24 additions and 14 deletions

View file

@ -1,6 +1,6 @@
service:
flush: 1
log_level: info
log_level: debug
pipeline:
inputs:
@ -8,29 +8,20 @@ pipeline:
listen: 0.0.0.0
port: 8889
processors:
logs:
- name: opentelemetry_envelope
- name: content_modifier
context: otel_resource_attributes
action: upsert
key: service.name
value: fluent-bit
outputs:
- name: stdout
match: '*'
- name: opentelemetry
match: '*'
host: 'test.oneuptime.com'
host: 'local.genosyn.com'
port: 443
metrics_uri: '/otlp/v1/metrics'
logs_uri: '/otlp/v1/logs'
traces_uri: '/otlp/v1/traces'
tls: On
header:
- x-oneuptime-token 1e603f70-b3c8-11ef-9018-bdd11a3584d1
- x-oneuptime-token ad29ff90-100f-11f0-a779-39a19251c0cf
- x-oneuptime-service-name demo-service-1

View file

@ -11,6 +11,9 @@ extensions:
- action: upsert
key: x-oneuptime-token
from_context: x-oneuptime-token
- action: upsert
key: x-oneuptime-service-name
from_context: x-oneuptime-service-name
processors:

View file

@ -45,7 +45,10 @@ import TelemetryService from "Common/Models/DatabaseModels/TelemetryService";
export default class OtelIngestService {
@CaptureSpan()
public static getServiceNameFromAttributes(attributes: JSONArray): string {
public static getServiceNameFromAttributes(
req: ExpressRequest,
attributes: JSONArray,
): string {
for (const attribute of attributes) {
if (
attribute["key"] === "service.name" &&
@ -60,6 +63,16 @@ export default class OtelIngestService {
}
}
// if there's no service name, check header for x-oneuptime-service-name
const serviceName: string = req.headers[
"x-oneuptime-service-name"
] as string;
if (serviceName) {
return serviceName;
}
return "Unknown Service";
}
@ -86,6 +99,7 @@ export default class OtelIngestService {
for (const resourceLog of resourceLogs) {
const serviceName: string = this.getServiceNameFromAttributes(
req,
((resourceLog["resource"] as JSONObject)?.[
"attributes"
] as JSONArray) || [],
@ -283,6 +297,7 @@ export default class OtelIngestService {
for (const resourceMetric of resourceMetrics) {
const serviceName: string = this.getServiceNameFromAttributes(
req,
((resourceMetric["resource"] as JSONObject)?.[
"attributes"
] as JSONArray) || [],
@ -513,6 +528,7 @@ export default class OtelIngestService {
// get service name from resourceSpan attributes
const serviceName: string = this.getServiceNameFromAttributes(
req,
((resourceSpan["resource"] as JSONObject)?.[
"attributes"
] as JSONArray) || [],