Tutorial: Route Data to Spotflow Grafana
This tutorial will show you how to configure the Platform to forward your data from the Device to the integrated instance of Grafana.
Requirements
- If you are not registered to the Spotflow IoT Platform yet, Sign Up.
- Existing Stream.
A Stream called
default-stream
in Stream Groupdefault-stream-group
is created automatically after you register. If you want to use a different Stream create a new one by following Create Stream tutorial. - Existing Provisioning Token.
We've already configured the Stream default-stream
in the Stream Group default-stream-group
to route incoming data to the integrated instance of Grafana.
Configure Route to Spotflow Grafana
- Portal
- CLI
- API
Open the link Data Flows in the left sidebar.
You'll see the list of Streams that are organized into Stream Groups. Click the Stream you want to configure routing to Spotflow Grafana for.
On the right side of the screen, you see the detailed configuration of the Stream. These options influence where the data are stored and how they are processed. Click the Egress tab.
The section Routes shows all the Egress Sinks where the Stream forwards the data it receives. The list is empty by default. Click Create new route.
Enter a machine-readable Name (allowed are only alphanumeric characters,
-
,_
, and.
) such asroute-to-grafana
. In the selection box Egress Sink, select Grafana. Click Save.Nice! Now you should see the newly created Egress Route in the list.
Supposing you have already installed the CLI and logged in,
replace placeholders <Your Stream Group Name>
and <Your Stream Name>
with your Stream Group name, and your Stream name and run the following command:
spotf stream egress-route create-or-update grafana --stream-group-name "<Your Stream Group Name>" --stream-name "<Your Stream Name>" --egress-route-name "route-to-grafana"
The CLI will confirm the creation and display the Egress Route details:
info: Spotflow.IotPlatform.Cli.App.Commands.DataFlows.Streams.EgressRoutes.StreamEgressRouteCreateOrUpdateEventHubCommand[0]
Egress Route 'route-to-grafana' for Stream '<Your Stream Name>' in Stream Group '<Your Stream Group Name>' created successfully.
Name: Grafana
WorkspaceId: 52aefb52-6ed8-453e-83e9-0048511f7ce9
StreamGroupName: <Your Stream Group Name>
StreamName: <Your Stream Name>
Properties
├── IsEnabled: true
├── EgressSinkName: Grafana
├── Config
└── Input: Messages
The following instructions expect that you have already obtained the API access token from the Portal and that you know the ID of the Workspace you want to use. If you don't know the Workspace ID, you can find it in the Portal under the link Workspaces in the left sidebar.
Replace the placeholders <Your Workspace ID>
, <Your API Access Token>
, <Your Stream Group Name>
and <Your Stream Name>
with your Workspace ID, API access token,
your Stream Group name, your Stream name and run the following command to create a new Egress Route:
- cURL
- PowerShell
curl -X PATCH 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/<Your Stream Group Name>/streams/<Your Stream Name>/egress-routes/route-to-grafana' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <Your API Access Token>' \
-d '{"properties": {"egressSinkName": "route-to-grafana"}}'
(Invoke-WebRequest -Method Patch -Uri 'https://api.eu1.spotflow.io/workspaces/<Your Workspace ID>/stream-groups/<Your Stream Group Name>/streams/<Your Stream Name>/egress-routes/route-to-grafana' `
-Headers @{
'Content-Type' = 'application/json'
'Accept' = 'application/json'
'Authorization' = 'Bearer <Your API Access Token>'
} `
-Body '{"properties": {"egressSinkName": "route-to-grafana"}}').Content
The API will confirm the creation and display the Egress Route details:
{
"name": "route-to-grafana",
"workspaceId": "<Your Workspace ID>",
"streamGroupName": "<Your Stream Group Name>",
"streamName": "<Your Stream Name>",
"version": 1,
"properties": {
"isEnabled": true,
"egressSinkName": "Grafana",
"config": {},
"input": "Messages"
}
}
What's Next
- Feel free to explore the received data in Spotflow Grafana.