Skip to content

Send custom metrics to DataDog #31

Discussion options

You must be logged in to vote

Hi folks, I worked with OPA a few months ago and we needed to send the test evaluation with Conftest to our SIEM and I built a little code to do it. Here the code.

headers = {
	"Content-Type": "application/json",
	"DD-API-KEY": object.get(opa.runtime().env, "DD_API_KEY", ""),
}

body(resources) = {
	"ddsource": object.get(opa.runtime().env, "CI_PROJECT_ID", ""),
	"hostname": "security_OPA_rules",
	"message": resources,
}

sendResult(resources) = {http.send({
	"method": "POST",
	"url": "https://http-intake.logs.datadoghq.com/v1/input",
	"headers": headers,
	"body": body(resources),
})}

# you can call to sendResult(resources) from here
sendResult(json.marshal(message))

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lucasrampoldi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment