Insights
Insights & Data Tags¶
In the Kelvin UI and in the Kelvin SDK, Data Tags are now known as Insights.
In the Kelvin SDK, the Data Tag names are deprecated in favor of the Insight names. Use Insight, app.on_insight and filters.is_insight instead of DataTag, app.on_data_tag and filters.is_data_tag in new code.
Backwards compatibility only
DataTag, app.on_data_tag and filters.is_data_tag still work, but for backwards compatibility only. Any new programs should use Insight, app.on_insight and filters.is_insight.
If possible, update your older programs that use the old names to the new ones to future-proof them.
Note
The rename applies to the Kelvin SDK only. The Kelvin API and the Kelvin API Client (Python) still use the Data Tag names, for example app.api.data_tag. In app.yaml the section is still data_tags.
Insights Management¶
You can also manage your insights using the Kelvin SDK and Kelvin API.
You can read all the details in the Platform Administration in the Insights section.
Insight Messages¶
Applications can receive Insight messages published by other Applications or created manually through the Kelvin UI. This allows your Application to react to labeled events on Asset time series data.
Each received Insight has an acceptance attribute, set by the platform. It is accepted, or snoozed while the Insight type is snoozed for the Asset.
Live¶
Receive insights in real time as they are published. Use this for event-driven reactions within a running Application.
app.yaml setup¶
To consume insights, declare the tag names your Application should receive in the data_tags.inputs section of your app.yaml. Each entry is the tag name as a string:
Decorator (Preferred)¶
The preferred method is to use the @app.on_insight decorator. You can filter by tag name using app.app_configuration to limit processing to only the tags your Application cares about.
Callback¶
For advanced scenarios, assign a handler function directly to app.on_insight:
| on_insight Callback Example | |
|---|---|
Historical¶
Query insights over a past time range using the Kelvin API. Use this for catching events that occurred before your Application started, or for periodic reconciliation.
Historical Data Tag Queries¶
In addition to receiving live insights via on_insight, you can query historical insights over a time range using app.api.data_tag.list_data_tag(). The Kelvin API Client (Python) keeps the Data Tag names. This is useful for catching events that occurred before your Application started, or for periodic reconciliation.
API permission required
You must declare the required read permission for data_tag in your app.yaml. Confirm the exact permission string from the method docstring in kelvin.api.client.api.data_tag before setting it.
See the API Integration page for full details on using app.api.
The example below fetches all "Temperature Too High" tags for a specific Asset over the past 3 days:
Recommended architecture
- Use
on_insightfor live events. - Add a startup task or scheduled job (for example, running every hour) to call the historical fetch. This ensures you do not miss events caused by downtime or redeployments.
See Background Tasks for how to schedule periodic work in a Application.