-2

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.

4
  • Seem its already answered, Please refer stackoverflow.com/questions/26000336/… Commented Apr 29, 2019 at 11:22
  • What have you tried doing? Commented Apr 29, 2019 at 11:23
  • @yanivoliver : Hello.. I have fetched a mysql query result and converted into json format. I have to push the json data to new relic using the above command mentioned. Since, I am new to python, I don't have a clear idea of how to execute the above command using python. Thank you! Commented Apr 30, 2019 at 5:57
  • @Dhamodharan : Thank you so much. I think I missed that. Commented Apr 30, 2019 at 5:59

1 Answer 1

0

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.