diff --git a/docs/data-routing/4-destinations/16-logs.md b/docs/data-routing/4-destinations/16-logs.md new file mode 100644 index 00000000..44e3d267 --- /dev/null +++ b/docs/data-routing/4-destinations/16-logs.md @@ -0,0 +1,60 @@ +--- +title: logs +--- + +| | | +|---|:---:| +|__Latest Version__| `v1.0.0` | +|__Input Content Type__| `application/json` | + +:::usage +Sending data to Golioth Logs incurs usage costs after exceeding the free tier. +See [Golioth pricing](https://golioth.io/pricing) for more information. +::: + +The Logs destination sends data to [Golioth Logs](/device-management/logging). +Data must have arrived as or been transformed into JSON in order to be delivered +successfully. + +The data message timestamp will be used as the time for the entry in Golioth +Logs, and the following JSON fields are supported. + +| Attribute | Description | +|-----------|------------------------------------------------------------------------| +| `level` | String indicating the log level (`debug`, `info`, `warn`, `error`). | +| `module` | String indicating the module from which the log message was generated. | +| `msg` | String with log message contents. | + +Any additional JSON fields will be stored as metadata with the entry in Golioth +Logs. + +### Example Usage + +Because Golioth Logs is hosted by Golioth, no configuration or credentials are +required to deliver data to the service. + +```yaml + destination: + type: logs + version: v1 +``` + +### Example Input + +```json +{ + "level": "warn", + "module": "net_sockets", + "msg": "failed to send" +} +``` + +### Example Output + +```json +{ + "level": "warn", + "module": "net_sockets", + "msg": "failed to send" +} +``` diff --git a/docs/data-routing/5-examples/28-golioth-logs-cbor.md b/docs/data-routing/5-examples/28-golioth-logs-cbor.md new file mode 100644 index 00000000..4e5fa4b9 --- /dev/null +++ b/docs/data-routing/5-examples/28-golioth-logs-cbor.md @@ -0,0 +1,9 @@ +--- +title: Golioth Logs CBOR +--- +import Pipeline from '@site/src/components/usethispipeline' + +This simple example matches on any CBOR data message, transforms the payload to +JSON, then delivers it to [Golioth Logs](/device-management/logging). + + diff --git a/docs/device-management/4-logging/3-sending-logs.md b/docs/device-management/4-logging/3-sending-logs.md index 9da29515..6012064b 100644 --- a/docs/device-management/4-logging/3-sending-logs.md +++ b/docs/device-management/4-logging/3-sending-logs.md @@ -3,25 +3,11 @@ id: sending-logs title: Sending Logs --- -import Prerequisites from '/docs/_partials-common/prerequisites-platform-setup.md' -import { ProtocolPublishSample } from '/docs/_partials-common/protocol.mdx' - - - -Our platform provides functionality for tracking your devices logs, so you can have a better sense of things that are happening out in the field. - -An endpoint is provided on our gateways on the `/logs` path where the device can send log data. Right now only the CoAP gateway is available to use this service. - -Data can be sent using query parameters and also on the message body. The message body can be send in CBOR or JSON format and is going to be parsed and we will try to identify the known attributes as presented below. If the body is sent as plain text, it will be saved as the log entry message. - -> See the [Device API documentation](/reference/device-api/api-docs/logging) - -### Simulating device logs using `coap` - -You can simulate sending logs by using `coap` and POSTing data to the `/logs` endpoint. - -In the example bellow, we are sending the parameters `module`, `level` and `network` as query parameters and also a message in JSON format in the body containing the log `msg`. - - - -After sending a log entry you can search logs using `goliothctl`. Check the [next page](./searching-logs) for more details on how to do that. +Log messages are delivered to the Golioth Logs service via +[Pipelines](/data-routing). By default, any new Projects created on the Golioth +platform will have a [CBOR logs +Pipeline](/data-routing/examples/golioth-logs-cbor) configured automatically +that will deliver data to Golioth Logs. + +See the [Golioth Logs data destination](/data-routing/destinations/logs) for +more information. diff --git a/docs/reference/2-device-api/3-api-docs/5-logging.md b/docs/reference/2-device-api/3-api-docs/5-logging.md deleted file mode 100644 index 01a2470d..00000000 --- a/docs/reference/2-device-api/3-api-docs/5-logging.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -id: logging -title: Logging ---- - -[Logging Device Service](/device-management/logging) definitions over CoAP. - -How to use guides: - -- [Sending logs](/device-management/logging/sending-logs) - -### Interface - -| Method | Description | Path | Content Format | -| -------- | ----------- | ----- | -------------- | -| POST/PUT | Send logs | /logs | JSON/CBOR | - -### Parameters and attributes that are known and indexed: - -| Attribute | Description | Default | -| --------------------- | ----------------------------------------------------------------------------------- | ------- | -| `time` or `timestamp` | Timestamp of the log entry | now() | -| level | Log Level - Can be info/warn/error/debug | info | -| module | Internal module that is generating logs | | -| `msg` or `message` | Free form string with the log message | | -| | Any other attribute sent over this endpoint is bundled into a `metadata` attribute. | | diff --git a/firebase.json b/firebase.json index f25748ec..781072f4 100644 --- a/firebase.json +++ b/firebase.json @@ -229,6 +229,11 @@ "source": "/device-management/authentication{,/**}", "destination": "/connectivity/credentials", "type": 301 + }, + { + "source": "/reference/device-api/api-docs/logging", + "destination": "/data-routing/destinations/logs", + "type": 301 } ], "rewrites": [ @@ -492,6 +497,11 @@ "source": "/device-management/authentication{,/**}", "destination": "/connectivity/credentials", "type": 301 + }, + { + "source": "/reference/device-api/api-docs/logging", + "destination": "/data-routing/destinations/logs", + "type": 301 } ], "rewrites": [