Hello,
I use module http in metricbeat to get some values through an API.
The API return a json looking like that :
{
"items" : [ {
"timeSeries" : [ {
"metadata" : {
"metricName" : "allocated_vcores_cumulative",
"startTime" : "2020-02-03T14:12:56.168Z",
"endTime" : "2020-02-03T14:17:56.168Z",
"attributes" : {
"clusterName" : "cluster2",
}
},
"data" : [ {
"timestamp" : "2020-02-03T14:13:43.757Z",
"value" : 549.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:14:43.757Z",
"value" : 549.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:15:43.759Z",
"value" : 374.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:16:43.760Z",
"value" : 373.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:17:43.780Z",
"value" : 373.0,
"type" : "SAMPLE"
} ]
}, {
"metadata" : {
"metricName" : "available_vcores",
"startTime" : "2020-02-03T14:12:56.168Z",
"endTime" : "2020-02-03T14:17:56.168Z",
"attributes" : {
"clusterName" : "cluster2",
}
},
"data" : [ {
"timestamp" : "2020-02-03T14:13:43.757Z",
"value" : 159.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:14:43.757Z",
"value" : 159.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:15:43.759Z",
"value" : 334.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:16:43.760Z",
"value" : 335.0,
"type" : "SAMPLE"
}, {
"timestamp" : "2020-02-03T14:17:43.780Z",
"value" : 335.0,
"type" : "SAMPLE"
} ]
} ],
"warnings" : [ ]
} ]
}
Here is my setup in metricbeat :
- module: http
enabled: true
period: 5m
hosts: ["http://cluster.api.priv:1234"]
namespace: "api"
path: "/api/timeseries"
query:
contentType: "application/json"
json.is_array: false
metricsets:
- json
In Elasticsearch, i have a new field in the index "api.items" that contain the request result.
I can't set up a specific field that i want to store.
My wish is to store one document for each element in the array timeSeries with "metadata" and "data" fields.