I see we somehow got 11 entries through while we were trying different JSON formats and trying CURL vs Python CLI vs Python in a notebook. We probably made 3x-4x that number of requests.
Unfortunately we cannot seem to re-create it. We have tried several JSON formats, eg:
{"logtype": "accesslogs", "message": "hihi", "hostname": "desktop", "service": "processing-service", "timestamp": 1611696057}
[{"common": {"attributes": {"logtype": "accesslogs", "hostname": "desktop", "service": "processing-service"}}, "logs": [{"timestamp": 1611696377, "message": "yoyo!"}]}]
I sent both several times and we’re not seeing them show up today, either by tailing the logs in realtime or by searching for the message content.
I did run my CURL test again and it did result in a new NrIntegrationError so it would seem our Python calls are “working” (disappearing?) and our CURL calls are just bad JSON.
Here’s the output from one of our requests:
$ python ./newrelic_log_test.py
[{"common": {"attributes": {"logtype": "accesslogs", "hostname": "desktop", "service": "processing-service"}}, "logs": [{"timestamp": 1611697614, "message": "yoyo!"}]}]
<PreparedRequest [POST]>
"[{\"common\": {\"attributes\": {\"logtype\": \"accesslogs\", \"hostname\": \"desktop\", \"service\": \"processing-service\"}}, \"logs\": [{\"timestamp\": 1611697614, \"message\": \"yoyo!\"}]}]"
202
{'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Content-Length': '52', 'CF-Cache-Status': 'DYNAMIC', 'Vary': 'Accept-Encoding', 'cf-request-id': '07e2430577000005138bbce000000001', 'Server': 'cloud
flare', 'Connection': 'keep-alive', 'Access-Control-Allow-Credentials': 'true', 'Date': 'Tue, 26 Jan 2021 21:46:54 GMT', 'CF-Ray': '617d6de8bb2f0513-LAX', 'Access-Control-Allow-Methods': 'GET, POST, PUT, HEAD, OPTIONS', 'Content-Type': 'application/json;
charset=UTF-8', 'Access-Control-Allow-Origin': '*'}
{"requestId":"ae1fb610-001f-b000-0000-017740a9edfb"}
It is showing, in order:
- The CLI command
- The JSON string being given to the request
- The request object
- The request body from the request object
- The response code
- The response headers
- The response body
Are you able to query by that requestId and see where it may have gone?
Here is our test script, you can see the other structure we tried in there as well.
$ cat newrelic_log_test.py
import requests
import time
import json
url = 'https://log-api.newrelic.com/log/v1'
headers = {'X-License-Key':'xxYYzz', 'Content-Type':'application/json'}
# data = {'message':'hihi','logtype':'accesslogs','service':'processing-service','hostname':'desktop'}
# data['timestamp'] = int(time.time())
# print json.dumps(data)
# r = requests.post(url, headers=headers, json=json.dumps(data))
message = {'message':'yoyo!'}
message['timestamp'] = int(time.time())
data = {
"common": {
"attributes": {
"logtype": "accesslogs",
"service": "processing-service",
"hostname": "desktop"
}
},
}
data['logs'] = [message]
print json.dumps([data])
r = requests.post(url, headers=headers, json=json.dumps([data]))
print r.request
print r.request.body
print r.status_code
print r.headers
print r.content
Thanks!