Datadog Log Management Fundamentals free question 4 / 10 · Domain 2: Log Collection
To collect a log file written in Shift JIS, you set encoding: sjis in the logs configuration. This value is not spelled the way the Agent's supported values are. What happens, according to the documentation?
- Collection of this file stops, and an error shows up in the Agent status
- The Agent guesses the encoding from the content and reads it that way
- The unsupported value is ignored, and the file is read as UTF-8
- The value is read as a close spelling, and the file is read as Shift JIS
Show the answer and explanation
Answer: C
Why this is correct
The section "Log file encodings" says that by default the Datadog Agent assumes that logs use UTF-8 encoding, and that you specify the encoding parameter when your application logs use a different one. The supported values are utf-16-le and utf-16-be (Agent v6.23/v7.23) and shift-jis (Agent v6.34/v7.34). The page then says that if you provide an unsupported value, the Agent ignores the value and reads the file as UTF-8. sjis is not in the list, so it is ignored, and the Shift JIS characters arrive garbled. The value to write is shift-jis.
Why the other options are wrong
"The value is read as a close spelling, and the file is read as Shift JIS" … The page lists the exact supported values and says an unsupported value is ignored. A value is not matched to a similar entry in the list.
"Collection of this file stops, and an error shows up in the Agent status" … The page says the Agent ignores the unsupported value and reads the file as UTF-8. The file is still read, so its collection does not stop.
"The Agent guesses the encoding from the content and reads it that way" … The page has you name a non-UTF-8 encoding yourself with the encoding parameter. Without a supported value, the Agent assumes UTF-8.
Common pitfall
The encoding parameter only applies when type is set to file. If you change the encoding of a file the Agent is already tailing, it can produce garbled characters, because the Agent resumes from the previous byte offset, which may not line up with character boundaries. Rotating the file, replacing it, or restarting tailing from the beginning fixes this.