Forum Discussion
FYI, if you want to use Postman for posting to the LM Logs ingestion API endpoint, you’ll have to make some changes.
Cause:
LM decided to omit the /santaba/ portion of the URL. This means that when the pre-request script runs, it tries to pull out the endpoint using the url variable, which still contains the /santaba/ portion. So, authentication will fail. Gotta love non-standard URLs for the API.
Resolution:
All you need to do is override the pre-request script for this one request. Technically, you could modify the url variable in your environment’s variable list, but if you do this, you’ll break all other requests.
Use the following pre-request script for just the POST into LM Logs:
var api_id = pm.environment.get('api_id');
var api_key = pm.environment.get('api_key');
var http_verb = request.method; // this is always POST for this request
var resource_path = '/log/ingest';
var epoch = (new Date()).getTime();
var request_vars = http_verb + epoch + request.data + resource_path;
var signature = btoa(CryptoJS.HmacSHA256(request_vars,api_key).toString());
var auth = "LMv1 " + api_id + ":" + signature + ":" + epoch;
pm.environment.set('auth', auth);
Then configure the url like this:
https://<account>.logicmonitor.com/rest/log/ingest
Replacing <account> with your account name. Select POST and put the logs in the body. This works in my Postman, so I’d be interested to know if this is the only change required to post logs into LM Logs from Postman.
Kudos go to
Related Content
- 2 years ago
- 7 months ago