Send data from AWS IoT to Axiom
This page explains how to route device log data from AWS IoT Core to Axiom using AWS IoT and Lambda functions
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to create, read, update, and delete datasets.
- Create an AWS account with permissions to create and manage IoT rules, Lambda functions, and IAM roles.
Create AWS Lambda function
Create a Lambda function with Python runtime and the following content. For more information, see the AWS documentation. The Lambda function acts as an intermediary to process data from AWS IoT and send it to Axiom.
In the environment variables section of the Lambda function configuration, add the following environment variables:
DATASET_NAME
is the name of the Axiom dataset where you want to send data.API_TOKEN
is the Axiom API token you have generated. For added security, store the API token in an environment variable.
This example uses Python for the Lambda function. To use another language, change the code above accordingly.
Create AWS IoT rule
Create an IoT rule with an SQL statement similar to the example below that matches the MQTT messages. For more information, see the AWS documentation.
In Rule actions, select the action to send a message to a Lambda function, and then choose the Lambda function you created earlier.
Check logs in Axiom
Use the AWS IoT Console, AWS CLI, or an MQTT client to publish messages to the topic that matches your rule. For example, iot/topic
.
In Axiom, go to the Datasets tab and select the dataset you specified in the Lambda function. You now see your logs from your IoT devices in Axiom.
Was this page helpful?