【问题标题】:Splunk Metrics {"text":"No data","code":5} errorSplunk Metrics {"text":"No data","code":5} 错误
【发布时间】:2020-08-26 22:04:13
【问题描述】:

我正在尝试通过 HEC 将指标发送到 Splunk,这是我的 curl 命令:

curl -k https://www.website.com                    \
-H "Authorization: Splunk password"       \
-d '{"index":"index-name","time": 313423232.000,"event":"metric","source":"disk","sourcetype":"perflog",
"host":"host_1.splunk.com","value":85,"fields":{"region":"us-west-1","datacenter":"dc1","rack":"63",
"os":"Ubuntu16.10","arch":"x64","team":"LON","service":"6","service_version":"0",
"service_environment":"test","path":"/dev/sda1","fstype":"ext3","metric_name:cpu.idle": 13.34}}'

作为回报,我得到: {"text":"无数据","code":5}

这很奇怪,因为它之前工作过,我添加的只是“值”:85。 问题可能出在我要发送到的网站上吗?

一些建议是不匹配的引号,以及 HEC 仅支持一组特定的已知字段的事实,但我不认为这是我在这里遇到的问题,因为我尝试运行相同的 curl 命令,只使用索引、源、时间、主机、源类型和事件,并得到相同的错误代码。

【问题讨论】:

  • 您使用的是什么 HEC 端点?你试过"value":"85"吗?

标签: curl metrics splunk


【解决方案1】:

要将指标发送到 Splunk HEC,您需要在名为 _value 的字段中包含指标值。您的示例中的最后一个参数也有一些错误。

以下请求应该足够了。

curl -k https://www.website.com                    \
-H "Authorization: Splunk password"       \
-d '{"index":"index-name","time": 313423232.000,"event":"metric","source":"disk","sourcetype":"perflog",
"host":"host_1.splunk.com","fields":{"region":"us-west-1","datacenter":"dc1","rack":"63",
"os":"Ubuntu16.10","arch":"x64","team":"LON","service":"6","service_version":"0",
"service_environment":"test","path":"/dev/sda1","fstype":"ext3","metric_name": "cpu.idle", "_value": 13.34}}'

【讨论】:

    【解决方案2】:

    我发现在得到代码 0 之前,我必须删除 Splunk 不喜欢的字段。

    curl -k ${SPLUNK_ENDPOINT}/services/collector -H "Authorization: Splunk ${SPLUNK_HEC_TOKEN}" -d '{"event": "Sourcetype test please", "sourcetype": "testsystem", "host": "some-host-123", "fields": {"tracking_id": 1234}}' ; echo 
    

    哪个会返回:

    {"text":"Success","code":0}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      • 2010-11-18
      • 2021-07-25
      • 1970-01-01
      • 2016-03-24
      • 1970-01-01
      相关资源
      最近更新 更多