Resource data collection from windows servers to Elasticsearch using cURL & JSON

Hi guys,

We have made a custom shell scripts to collect resource allocation, utilization data from Linux servers and pushing it to elastic and its runningsuccessfully. But not succeed on windows servers with same method due to parsing and limitation of json support on windows powershell.

Just consider my below script as sample format and looking someone help to make it work bez i am new to powershell scripting and JSON

Hear the above JSON format is not support directly in powershell. how to sort out this issue? or let me know how to collect similar data from windows server to elastic

cpu_utilization=C:\script\cpu.ps1
mem_utilization=C:\script\mem.ps1
disk_utilization=C:\script\disk.ps1
total_cpu=C:\script\totcpu.ps1
total_mem=C:\script\totmem.ps1
total_disk=C:\script\totdisk.ps1
tenant_id=C:\script\tenant.ps1
server_id=C:\script\server_id.ps1
appProfile_id=C:\script\app_id.ps1
dt_milli=Get-date

curl -XPUT http://10.5.5.5:9200/cloud/server-utilization/${host}_${dt_id} -d '
{
"cpu_util" : '${cpu_utilization}',
"mem_util" : '${mem_utilization}',
"disk_util" : '${disk_utilization}',
"hostname" : "'${host}'",
"tot_cpu" : "'${tot_cpu}'",
"tot_mem" : "'${tot_mem}'",
"tot_disk" : "'${tot_disk}'",
"timestamp" : "'${dt_id}'",
"time_milli" : '${dt_milli}',
"tenant_id" : "'${tenant_id}'",
"server_id" : "'${server_id}'",
"app_id" : "'${appProfile_id}'",
"uptime" : "'${uptime_duration}'"
}'

Thanks in advance,
Raj

Why not just use topbeat?
https://www.elastic.co/guide/en/beats/topbeat/current/index.html

Hello Mark Walkom,

I have checked with Metricbeat & topbeat, Both are similar in the way of metric collection.
they are able to collect "total allocated memory" but "total allocated CPU" is NOT available and It is top most required.

Another thing is unable to assign custom ID for my servers and tenant.

Thank you,
RAj