Export logs for Machine Learning Service API interactions
You can configure sensors and consoles to export logs of API interactions with the ExtraHop Machine Learning Service. The ExtraHop system exports API logs through HTTPS POST requests. Any HTTP server can receive the logs, as long as the server is reachable by the ExtraHop system and the server has a TLS certificate installed.
Configure an HTTP server to receive the logs
Before you begin
- You must install Go on your machine. For more information, see the Go documentation at https://go.dev/learn/.
Configure the sensor or console
You must configure the sensor or console to export logs to the server you configured.
- If the certificate for your server is not trusted by the built-in certificate on the sensor, you must add the certificate to the sensor or console.
API log format
The logs are exported in JSON format. Each log of an HTTPS request to the Machine Learning Service contains the following fields:
- sequence: Number
- A numerical ID that correlates requests and responses. For example, if a request has a sequence number of 1, the response log will also have a sequence number of 1.
- request: Object
- An object that contains details about the request. The object contains the
following fields:
- Close: Boolean
- Indicates whether the Connection header is set to close.
- ContentLength: Number
- The value of the ContentLength header.
- Header: Object
- An object that contains the HTTPS headers.
- Host: String
- The hostname of the server.
- Method: String
- The method of the request.
- Proto: String
- The HTTP protocol the request was sent with.
- RemoteAddr: String
- The IP address of the server.
- RequestURI: String
- The URI of the request.
- TLSVersion: String
- The TLS version the request was encrypted with.
- Trailer: String
- The value of the Trailer header.
- TransferEncoding: String
- The value of the Transfer-Encoding header.
- request_body: Object
- The JSON body of POST, PUT, and PATCH requests.
Each log for an HTTPS response from the Machine Learning Service contains the following fields:
- sequence: Number
- A numerical ID that correlates requests and responses. For example, if a request has a sequence number of 1, the response log will also have a sequence number of 1.
- response_status_code: Number
- The status code of the response.
- response_headers: Object
- An object that contains the HTTPS headers
- response_body: Object
- The JSON body of the response.
Example request
The following JSON object is an example of a log for an API request:
{ "sequence": 302, "request": { "Method": "POST", "Host": "appliance.example.extrahop.com", "RemoteAddr": "127.0.0.1:1234", "RequestURI": "/api/v1/metrics", "TLSVersion": "TLS1.2", "Proto": "HTTP/1.1", "ContentLength": 149, "TransferEncoding": null, "Header": { "Accept": [ "application/json" ], "Content-Length": [ "149" ], "Content-Type": [ "application/json" ] }, "Close": false, "Trailer": null }, "request_body": { "metric_category": "net", "from": -1, "object_type": "capture", "object_ids": [ 0 ], "until": 0, "metric_specs": [ { "name": "pkts" } ], "cycle": "30sec" } }
Example response
The following JSON object is an example of a log for an API response:
{ "sequence": 302, "response_status_code": "200", "response_headers": { "Content-Type": [ "application/json; charset=utf-8" ], "Vary": [ "Accept-Encoding" ] }, "response_body": { "cycle": "30sec", "node_id": 0, "clock": 1678150650000, "from": 1678150649999, "until": 1678150650000, "stats": [ { "oid": 0, "time": 1678150650000, "duration": 30000, "values": [ 1260 ] } ] } }
Thank you for your feedback. Can we contact you to ask follow up questions?