llama
2 months agoNeophyte
Datasource - Extract dates from a json response.
Hi,
I'm writing a datasource logic module to pull the system certificates from Cisco ISE to track the expiry date, similar to SSL certificates.
I can get the response back but when i create the datapoints, they don't populate, could someone advise?
// import the logicmonitor http and jsonslurper classes
import com.santaba.agent.groovyapi.http.*
import groovy.json.JsonSlurper
// setup
ip = hostProps.get('system.hostname')
user = hostProps.get('ise.monitoring.user')
pass = hostProps.get('ise.monitoring.pass')
host = hostProps.get('auto.system_name')
// base64 encoding un+pw for basic auth header
auth_string = user + ':' + pass
encodedString = auth_string.bytes.encodeBase64()
auth = 'Basic ' + encodedString
// open a connection
httpClient = HTTP.open(ip, 443)
// define api endpoint
url = "https://${ip}/api/v1/certs/system-certificate/${host}"
// create headers
headers = [:]
headers['Authorization'] = auth
headers['Content-Type'] = 'application/json'
// get request to api endpoint
getResponse = httpClient.get(url, headers)
// get status code
statusCode = httpClient.getStatusCode()
// close connection
httpClient.close()
// parse response and error handling
if (statusCode == 200) {
response = new JsonSlurper().parseText(httpClient.getResponseBody())
println response['response']
} else {
return 1
}
return 0
my datapoint is setup as below:
DP Source: Content the script writes to standard output
Interpret with: regex
Regex:
expirationDate:\S*\s\S*\s\S*\s\S*\s\S*\s\d*
Metric type: derive
you can see from the attachment that i get no data, I've also attached the output from the collector debug