Setting default severity / status#
The log lines ingested from the previous scenarious contain no severity information (eg. DEBUG
, INFO
, WARN
, ERROR
etc).
Setting the correct log severity is important for downstream users to understand how "bad" the log line is - is it simply an informational message or a serious error?
These severities will also be used in later scenarios to (for example) conditionally drop or re-route logs based on their severity.
For now, let's assume that, where a severity is not explicitly set (all of our log lines), we want to default the lines to an INFO
level log line.
scenario4.yaml shows the OpenTelemetry collector configuration to achieve this.
Look Again#
Look again at the collector debug output from scenario 3. You should see that the SeverityText
and SeverityNumber
are both empty / unspecified.
LogRecord #1
ObservedTimestamp: 2025-03-27 06:04:05.298857978 +0000 UTC
Timestamp: 1970-01-01 00:00:00 +0000 UTC
SeverityText:
SeverityNumber: Unspecified(0)
Body: Str(My third dummy log line...)
Attributes:
-> log.file.name: Str(file.log)
-> log.file.path: Str(/workspaces/demo-opentelemetry-patterns/file.log)
Stop Previous Collector#
If you haven't done so already, stop the previous collector process by pressing Ctrl + C
.
Start Collector#
Run the following command to start the collector:
/workspaces/$RepositoryName/dynatrace-otel-collector --config=/workspaces/$RepositoryName/scenario4.yaml
Generate Log Data#
Open file.log
file and add this line then save the file.
My fourth dummy log line...
Verify Debug Data in Collector Output#
View the collector terminal window and verify that the SeverityText
and SeverityNumber
fields are now correctly set:
...
SeverityText: INFO
SeverityNumber: Info(9)
Body: Str(My fourth dummy log line...)
...
View Data in Dynatrace#
Tip
Right click and "open image in new tab" to see large image
Click the Run
button again on the DQL tile. You should see the new data.
Reminder, the DQL statement is:
fetch logs
| filter contains(content, "dummy log line")
Congratulations! The log lines now have the correct timestamps.