diff --git a/FluentBit/etc/fluent-bit.yaml b/FluentBit/etc/fluent-bit.yaml index c35ae666d7..81d19a5916 100644 --- a/FluentBit/etc/fluent-bit.yaml +++ b/FluentBit/etc/fluent-bit.yaml @@ -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 \ No newline at end of file diff --git a/OTelCollector/otel-collector-config.template.yaml b/OTelCollector/otel-collector-config.template.yaml index ace24f5cde..a4e0a45100 100644 --- a/OTelCollector/otel-collector-config.template.yaml +++ b/OTelCollector/otel-collector-config.template.yaml @@ -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: diff --git a/OpenTelemetryIngest/Services/OtelIngest.ts b/OpenTelemetryIngest/Services/OtelIngest.ts index 951ae93efa..82e4df4cdf 100644 --- a/OpenTelemetryIngest/Services/OtelIngest.ts +++ b/OpenTelemetryIngest/Services/OtelIngest.ts @@ -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) || [],