HTTP¶
The http
API is unique among the supported endpoints in that it does not implement an existing specification. It is a generic endpoint and a convenient method of ingesting data over HTTP.
Endpoint |
http |
---|---|
URL |
|
Maximum Request Size |
10MB |
Ingesting data over HTTP¶
You can send a POST request to Observe. Observe makes sense of the POST request based on the following principles:
Observe parses the request body according to the content type header.
The path component of the URL encodes as a tag.
Query parameters encoded as tags.
Up to 1 MB per observation, or 10 MB uncompressed per payload. 4 MB per request recommended.
As an example, the following POST:
$ curl -X POST https://${OBSERVE_CUSTOMER?}.collect.observeinc.com/v1/http/first/example?key=value \
--user ${OBSERVE_TOKEN?} \
-H 'Content-Type: application/json' \
-d '{"message":"Hello World!"}'
Returns in an observation with the following values:
Column |
Value |
---|---|
OBSERVATION_KIND |
http |
FIELDS |
{"message": "Hello World!"}
|
EXTRA |
{"key": "value", "path": "/first/example"}
|
The observation fields are based on the request body, while path
and query parameters are encoded in EXTRA
.
All observations in a payload are given the same EXTRA
metadata.
HTTP headers determine how the content is parsed.
For more about authentication, including Bearer token, see Authentication.
Supported content types¶
The HTTP endpoint supports the following content type values:
Content-Type |
Description |
---|---|
application/json |
Parses a single JSON object or array of objects. Each object is a unique observation. |
application/x-ndjson |
Parses a stream of newline delimited JSON objects. Each object is a unique observation. |
application/xml |
Internally converts XML object to JSON, and processes it according to
|
application/msgpack |
Parses an array of objects. |
text/csv |
Generates one observation per CSV record, using the fields defined in the header row. Empty values are omitted. |
text/plain |
Generates one observation per line. |
Note
There are several additional headers that also control data parsing.
JSON examples¶
Object¶
You can submit an object by setting the Content-Type
header to application/json
.
The object results in a single observation.
{
"message": "Hello World!"
}
$ curl -X POST https://${OBSERVE_CUSTOMER?}.collect.observeinc.com/v1/http/example \
--user ${OBSERVE_TOKEN?} --data-binary @payload \
-H 'Content-Type: application/json'
Array of objects¶
You can submit an array of objects by setting the Content-Type
header to application/json
.
Each object results in a separate observation.
[
{
"id": 1
},
{
"id": 2
}
]
$ curl -X POST https://${OBSERVE_CUSTOMER?}.collect.observeinc.com/v1/http/example \
--user ${OBSERVE_TOKEN?} --data-binary @payload \
-H 'Content-Type: application/json'
Newline delimited objects¶
If you have a stream of newline delimited objects, you can submit your data as content type application/x-ndjson
.
Each object results in a separate observation.
{
"id": 1
}
{
"id": 2
}
{
"id": 3
}
$ curl -X POST https://${OBSERVE_CUSTOMER?}.collect.observeinc.com/v1/http/example \
--user ${OBSERVE_TOKEN?} --data-binary @payload \
-H 'Content-Type: application/x-ndjson'