将数据从dataPower记录到splunk

时间:2018-07-13 12:28:14

标签: splunk ibm-datapower

这个问题可能看起来很简单,但是我对此颇感震惊。

我有一个要求,我必须将有关时间戳,等待时间,服务名称等的数据存储在变量中,然后将其记录到splunk中。

但是我无法通过datapower xslt调用splunk。

我们如何使用XSLT通过数据功能调用splunk

谢谢

2 个答案:

答案 0 :(得分:0)

Splunk具有多个接口,但是XSLT并不是其中之一。幸运的是,已经有一个Splunk应用程序可以从Datapower收集数据并对其进行索引。参见https://splunkbase.splunk.com/app/3517/

答案 1 :(得分:0)

我会考虑使用Splunk HTTP Event Collector

您可以将XSLT ou Gatewayscript与Datapower urlopen函数(两种语言都可用)结合使用,以对收集器进行简单的http调用。

我发现here(Apache许可下的代码)的调用与对带有以下主体的https://SPLUNK_SVR:8088/services/collector/event/1.0的调用一样简单:

{
    "source": "chicken coop",
    "sourcetype": "httpevent",
    "index": "main",
    "host": "farm.local",
    "event": {
        "message": {
            "chickenCount": 500
            "msg": "Chicken coup looks stable.",
            "name": "my logger",
            "put": 98884,
            "temperature": "70F",
            "v": 0
        },
        "severity": "info"
    }
}

我认为通过使用网关脚本在数据能力上会更好,请参见here。寻找第一个例子。您会发现类似的代码,其中我修改了“数据”部分:

//Could be added to a library    
var urlopen = require('urlopen');

var jsonData = '{
"source": "Datapower",
"sourcetype": "SOMETHING DYNAMIC",
"index": "main",
"host": "GET_THIS_FROM_DP_VARIABLES",
"event": {
    "message": {
        "SOMECOUNTER": 500
        "msg": "SOME INTERESTING INFORMATION.",
        "name": "GET_THIS_FROM_DP_VARIABLES",
        "put": 3333,
        "yadayada": "foo",
        "bar": 0
        },
        "severity": "info"
    }
}';

var options = {
            target: 'https://SPLUNK_SVR:8088/services/collector/event/1.0',
            method: 'POST',
           headers: { },
       contentType: 'text/plain',
           timeout: 60,
  sslClientProfile: 'AN_EXISTING_SSL_PROFILE_ON_DATAPOWER',
              data: jsonData};

urlopen.open(options, function(error, response) {
  if (error) {
    // an error occurred during the request sending or response header parsing
    console.error("Splunk Logging - urlopen error: "+JSON.stringify(error));
  } else {
    // get the response status code
    var responseStatusCode = response.statusCode;
    var responseReasonPhrase = response.reasonPhrase;
    console.log("Splunk Logging - status code: " + responseStatusCode);
    console.log("Splunk Logging - reason phrase: " + responseReasonPhrase);
    // no need to read response data - This is just logging
  }
});