It would be a great help if somebody helps me to understand how the following command can be executed using python:

curl -X POST https://insights-collector.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/events -H "Content-Type: application/json" -H "X-Insert-Key: YOUR_KEY_HERE" -d '{"eventType":"Custom Event Name", "attribute1": "value"}'

SQL query results need to be converted to JSON format and need to be pushed to new relic using the above command.

1 Answers

0
panda On

try doing this

import requests

headers = {
    'Content-Type': 'application/json',
    'X-Insert-Key': 'YOUR_KEY_HERE',
}

data = '{"eventType":"Custom Event Name", "attribute1": "value"}'

response = requests.post('https://insights-collector.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/events', headers=headers, data=data)