...
https://docs.microsoft.com/en-us/azure/azure-monitor/logs/data-collector-api
Authorization Header
Any request to the Azure Monitor HTTP Data Collector API must include an authorization header. To authenticate a request, you must sign the request with either the primary or the secondary key for the workspace that is making the request. Then, pass that signature as part of the request.
Here's the format for the authorization header:
Code Block |
---|
Authorization: SharedKey <WorkspaceID>:<Signature> |
WorkspaceID is the unique identifier for the Log Analytics workspace. Signature is a Hash-based Message Authentication Code (HMAC) that is constructed from the request and then computed by using the SHA256 algorithm. Then, you encode it by using Base64 encoding.
Use this format to encode the SharedKey signature string:
Code Block |
---|
StringToSign = VERB + "\n" +
Content-Length + "\n" +
Content-Type + "\n" +
"x-ms-date:" + x-ms-date + "\n" +
"/api/logs"; |
Here's an example of a signature string:
Code Block |
---|
POST\n1024\napplication/json\nx-ms-date:Mon, 04 Apr 2016 08:00:00 GMT\n/api/logs |
When you have the signature string, encode it by using the HMAC-SHA256 algorithm on the UTF-8-encoded string, and then encode the result as Base64. Use this format:
Code Block |
---|
Signature=Base64(HMAC-SHA256(UTF8(StringToSign))) |
Request Body
The body of the message must be in JSON.
It must include one or more records with the property name and value pairs in the following format. The property name can only contain letters, numbers, and underscore (_).
Code Block |
---|
JSON [ { "property 1": "value1", "property 2": "value2", "property 3": "value3", "property 4": "value4" } ] |
...