如何将自定义字段添加到 Splunk 中的事件?

How to add custom field to events in Splunk?

我想将自定义字段添加到特定索引并让它们相应地记录。

目前只有"host"、"index"、"sourcetype"等几个默认字段...

不确定这是否是添加额外数据的最佳位置。

如何添加更多字段?

我目前正在使用 Splunk SDK 提交事件。

您用如此少的事件测试 Splunk 是在伤害自己。它们不会让您看到 Splunk 可以做什么。您只会获得默认字段,因为 Splunk 不知道如何处理单个单词。如果你有类似 "foo=bar" 的东西,那么你会看到 Splunk 创建了 'foo' 字段。

每台计算机至少有一个日志文件可用于测试 Splunk。

可以使用转换向事件添加字段。这样做是一个高级主题,不能使用 GUI 来完成。我建议你在尝试 运行.

之前使用更好的样本数据学习走路

我还想提一下,我是通过 Splunk SDK 提交事件的。

为了获得我想在活动中显示的字段,我必须提交活动数据作为活动名称。

    var myindexes = service.indexes();
    // Submit an event to the index
    myindexes.fetch(function (err, myindexes) {
    let myindex = myindexes.item("audits-client");


    let evtData = {
        timestamp: Date.now(),
        userAgent: headers['user-agent'],
        protocol: "http",
        file: "null"
    }

    myindex.submitEvent(evtData, {

        sourcetype: "web"

    }, function (err, result, myindex) {
        console.log("Submitted event: ", result);
        return result
    });
});