【问题标题】:How can I send the content of the file to HTTP Event Collector in Splunk?如何将文件内容发送到 Splunk 中的 HTTP 事件收集器?
【发布时间】:2021-09-08 05:57:00
【问题描述】:

我正在使用一个脚本,它给我一些 json 格式的数据,我想把这些数据发送到 splunk。 我可以将脚本的输出存储在文件中,但如何将其发送到 HTTP 事件收集器?

我尝试过但没有成功的几件事:


FILE="output.json"
file1="cat answer.txt"
curl -k "https://prd-pxxx.splunkcloud.com:8088/services/collector"  -H "Authorization: Splunk XXXXX"  -d  '{"event": "$file1", "sourcetype": "manual"}'

-----------------------------------------------------------

curl -k "https://prd-pxxx.splunkcloud.com:8088/services/collector" -H "授权:Splunk XXXXX" -d '{"event": "@output.json", "sourcetype ": "手动"}'


curl -k "https://prd-p-w0gjo.splunkcloud.com:8088/services/collector"  -H "Authorization: Splunk d70b305e-01ef-490d-a6d8-b875d98e689b"   -d '{"sourcetype":"_json", "event": "@output.json", "source": "output.json}

-----------------------------------------------------------------

After trying this I understand that it literally sends everything specified in the event section. Is there a way I can send the content of the file or use a variable? 

Thanks in advance!

【问题讨论】:

    标签: http events splunk collectors


    【解决方案1】:

    (注意 - 我没有专门尝试过这个,但它应该能让你接近)


    根据Docs.Splunk on HTTP Event Collector Examples #3,您似乎可以做一些与此非常相似的事情:

    curl -k "https://mysplunkserver.example.com:8088/services/collector/raw?channel=00872DC6-AC83-4EDE-8AFE-8413C3825C4C&sourcetype=splunkd_access&index=main" \
        -H "Authorization: Splunk CF179AE4-3C99-45F5-A7CC-3284AA91CF67" \
        -d < $FILE
    

    假设文件的内容格式正确,它应该直接进入。

    文件是如何创建的?它是否在托管端点上的部署应用程序中?如果是这样,可能设置一个scripted input 让 UF 以您选择的任何时间表运行会更简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 2018-01-25
      • 1970-01-01
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      相关资源
      最近更新 更多