splunk / splunk/splunk-library-javalogging

Add fields to log message using HttpEventCollectorLogbackAppender

Open
#263 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
140
Forks
173
PR merge metrics
No merged PRs in 30d

Description

curl -k https://<host>:443/services/collector/event -H "Authorization: Splunk <token>" -d '{"event": "Hello, world!", "sourcetype": "test-sourcetype", "host": "test-host", "source": "test-source", "fields":{"app_id":"999999999"}}'

I am trying to replicate the log event above using the HttpEventCollectorLogbackAppender. I can send everything to Splunk except the "fields".

I can see that there is a fields property being added in HecJsonSerializer, and that is for metadata not in the MetadataTags.HEC_TAGS set. I think this is what I need, but I can't figure out a way to add metadata outside that Set through the XML configuration. The metadata is list fixed in lines 75-88 of HttpEventCollectorLogbackAppender.java. How can we add metadata like in the curl request above without having to extend HttpEventCollectorLogbackAppender?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with HecJsonSerializer and the metadata handling in HttpEventCollectorLogbackAppender.java, especially lines 75-88, then trace how metadata is read from XML configuration. Compare the appender's generated event with the curl example's fields object. Done means XML configuration can supply metadata outside MetadataTags.HEC_TAGS without requiring a subclass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.