Getting Started
7 Lessons
Section
















A camera that cannot see is a camera that cannot do its job. AXIS Image Health Analytics watches for that. It raises an alarm when the view is blocked, redirected, blurred, or underexposed, and it clears the alarm when the image is usable again. On compatible cameras with AXIS OS 12.0 or later it is already installed.
Operators want those alarms. A blocked lens or a camera that has been turned away should reach a person, not sit in a log until someone happens to look. The trouble is that the same detection also fires when the scene is merely difficult. Heavy rain or snow can keep a lens reading as blocked for hours, or for days. Each flicker is a new notification. Notifications pile up, and the alarm that mattered is lost in the noise.
The usual fix is to turn the detection off until the weather passes. That works until someone forgets to turn it back on. The next real blockage then never raises an alarm.
⚠ Note that this guide requires the FixedIT Data Agent v1.7 release which is currently in unofficial preview. You can request early access by sending an email to [email protected] or contacting us directly.
In this guide, we will gradually solve a few problems. If you are only interested in the final solution, you can skip to the Final Solution section near the bottom.
First, we will show how to use the FixedIT Data Agent to subscribe to the events from AXIS Image Health Analytics and write these to the logs tab in the FixedIT Data Agent UI.
After that, we will show how to use the open-source ntfy service to send push notifications to a phone or a computer, directly from the Axis camera. The cloud version is free for anyone to use, even without any registration. If you want to run your own server, you can also self-host it. All you need to test this is an Axis camera with internet access and a phone or computer to receive the notifications.
Then, we will show how to add more logic to the alert pipeline. We will start by adding periodic digests of the alerts. For example, every hour you will receive a notification if there has been at least one alert during the last hour. That message will include the number of alerts for each type that occurred during the last hour.
We will then add rate limiting to the alerts. If more than 5 alerts happens with less than one hour between them, the notifications will be paused. But we will also send a new higher-priority notification stating that further notifications will be paused. Once there has been an hour without any alerts, the notifications will automatically resume.
The first step in doing something interesting is to ingest the data. Just like in the quick-start guide or the Hello, World! project, we will make use of configuration files to tell the FixedIT Data Agent what to do.
The following configuration file creates an input that subscribes to the AXIS Image Health Analytics "Any" event.

You can use the Development→Event tab in the FixedIT Data Agent to find the detailed information about the available events.
[[inputs.execd]]
command = [
"${EXECUTABLES_DIR}/event_handler", "--subscribe", "--config-inline",
"""
[topics]
topic_0 = AcapOnvifEvent
topic_0_namespace = tns1
topic_1 = AXISImageHealthAnalytics
topic_2 = Any-Active-Events
[settings]
namespace = unqualified
[item.Cause]
namespace = tns1
data_type = string
[item.active]
namespace = tns1
data_type = bool
"""
]
data_format = "influx"To test this, we also need an output. Let's start with logging the ingested events to stdout which will expose them under the Logging→Pipeline Data tab in the FixedIT Data Agent UI.
[[outputs.file]]
namepass = ["Any-Active-Events"]
files = ["stdout"]
data_format = "template"
metric_batch_size = 1
template = '''
------------------------------------------------------------
Image health event
time: {{ .Time.Format "2006-01-02 15:04:05 MST" }}
topic: {{ .Tag "topic" }}
cause: {{ .Field "Cause" }}
active: {{ .Field "active" }}
------------------------------------------------------------
'''The default name of metrics produced by the event subscriber plugin is the topic_2 value, in this case Any-Active-Events. We use the template output data format to pretty-print the message.
When adding the two snippets above to your configuration files and enabling them, you will directly see the event status in the Logs→Pipeline Data tab. If not, make sure that your device has the AXIS Image Health Analytics app installed, configured and running.

Now, let's make things a bit more interesting by pushing real-time notifications to your phone or computer. Navigate to the ntfy web app and press Subscribe to topic. Create a name for your event topic. Since the free test server is shared, you need to have a unique topic name to prevent collision with other users.

Now when you have a topic to send the notifications to, add the following config block to the FixedIT Data Agent.
[[outputs.http]]
namepass = ["Any-Active-Events"]
url = "${NTFY_TOPIC_URL}"
method = "POST"
timeout = "10s"
data_format = "template"
use_batch_format = false
metric_batch_size = 1
template = '{{ if .Field "active" }}{{ .Field "Cause" }} is active{{ else }}{{ .Field "Cause" }} cleared{{ end }}'
[outputs.http.headers]
Content-Type = "text/plain; charset=utf-8"
Title = "Image health event"
Tags = "camera"Where in your configuration file you place this block does not matter since outputs always runs after all inputs and processors.
We use the HTTP output to send the notification. We disable use_batch_format and sets metric_batch_size to 1 to make sure that each notification is sent directly when they are created.
Instead of hard-coding the topic in the config file, we make use of an environment variable (${NTFY_TOPIC_URL}). Go to the Configuration→Variables tab in the FixedIT Data Agent, click the plus icon under the "Extra Telegraf variables" section and add a new variable with the name NTFY_TOPIC_URL and the value set to the same string you used to create the topic in the ntfy service.

With this added, you should directly get a notification with the current status of the event.

The reason this message is sent directly is that the Any-Active-Events event is a stateful event. Stateful events always have a value, and directly when you subscribe to it you will get a first message with the current value. This might not always be what you want, so in the next section we're going to add logic to conditionally ignore the first message.
The first message is sent directly when the workflow starts and connects to the event source. Pushing a notification make sense only if the first message indicates that there is currently a health issue, not if the first message reports that everything looks good.
The easiest way to detect if a message is the first message after connection is to use the cumulative_sum processor to add a sequential index to each message. The processor itself is an accumulator, but by appending a static one to each metric and accumulating that, we will get an index starting at 1, then 2, then 3, etc... Add the following configuration block to one of your files:
[[processors.defaults]]
namepass = ["Any-Active-Events"]
[processors.defaults.fields]
state_change = 1
[[processors.cumulative_sum]]
namepass = ["Any-Active-Events"]
fields = ["state_change"]The first processor adds a new field named state_change which is always one. The second processor accumulates this and creates a new field called state_change_sum with the incrementing index.
You can now use this value with the Common Expression Language in the metricpass option like metricpass = "fields.state_change_sum > 1 || fields.active == true". This rule tells the output plugin to only send the message if its not the first metric after a start, or the alarm is already active. Add this option anywhere in the [[outputs.http]] output (but before the nested [outputs.http.headers] table). The complete output will now look like this:
[[outputs.http]]
namepass = ["Any-Active-Events"]
metricpass = "fields.state_change_sum > 1 || fields.active == true"
url = "${NTFY_TOPIC_URL}"
method = "POST"
timeout = "10s"
data_format = "template"
use_batch_format = false
metric_batch_size = 1
template = '{{ if .Field "active" }}{{ .Field "Cause" }} is active{{ else }}{{ .Field "Cause" }} cleared{{ end }}'
[outputs.http.headers]
Content-Type = "text/plain; charset=utf-8"
Title = "Image health event"
Tags = "camera"When enabling the files, you will see that you no longer get any notification at the start of the workflow (unless the camera is already blocked/blurred). Try triggering the event by blocking the camera or setting the focus to a poor value.
You will see in the AXIS Image Health Analytics application that the use case is marked with "!Detected" and you should get a push notification about the event. You will also see that you get a new notification when the alarm clears.

There are four different use cases that can be enabled, and the one triggering the alarm is what is stored in the Cause field.
A live notification tells you that something just happened. A regular report answers a different question: how often did it happen over a stretch of time? If you need the first, the other, or both combined depends on your use case. We will show how to add the regular report while keeping the live alerts. You can mix and match these config blocks depending on your unique use case.
Once an hour, the camera can send one summary of the alarms that occurred during that hour. One message will be sent for each Cause (Blurred, Blocked, etc) and it specifies how many times it became active. If the hour had no alarms, nothing is sent. You only hear from the camera when there is something to highlight.
Before we go into creating the actual counts for the report, there are some preparation we need to do of the messages. The first thing is to separate activations (when an alarm goes active) from clears (when an alarm goes back to normal state). We can do this by renaming the messages using the override processor and the same metricpass option as we used before.
[[processors.override]]
namepass = ["Any-Active-Events"]
metricpass = "fields.active == true"
name_override = "health_event_activated"
[[processors.override]]
namepass = ["Any-Active-Events"]
name_override = "health_event_deactivated"The next thing we will do is to promote the Cause field to a tag. In Telegraf metrics, there are fields and tags. Cause was created as a field, but the usual way to separate different data streams in Telegraf is to use tags. Since we want to have independent counters for the different Causes, we will need to promote the Cause field to a tag instead. We do this with the converter processor.
[[processors.converter]]
namepass = ["health_event_activated", "health_event_deactivated"]
[processors.converter.fields]
tag = ["Cause"]Now, we are finally ready to use the valuecounter aggregator to count the instances of each Cause during a time window.
The value counter counts how many messages arrived during a time window, then emits one summary when that window ends. This makes the plugin an aggregator rather than a processor. A processor looks at one metric at a time and can change it, rename it, or drop it, then immediately passes the result on. An aggregator waits until the window closes, then emits a new summary.
If nothing is fed into the value counter during a window, it stays silent. You only get a digest for periods that had at least one counted message.
Add this block to your configuration file:
[[aggregators.valuecounter]]
namepass = ["health_event_activated"]
name_override = "image_health_stats"
period = "${STATS_PERIOD:-1h}"
fields = ["active"]
# Leave the original metric untouched so it can be used again
# by other plugins.
drop_original = falseThe reporting period is specified by an environment variable, STATS_PERIOD, and it defaults to one hour. If you want to change the period duration, add the STATS_PERIOD as a new variable in the same way as you added the NTFY_TOPIC_URL and set the value to e.g. 24h.
By default the windows snap to the wall clock. The [agent] setting round_interval controls that, and it defaults to true. The boundary comes from STATS_PERIOD: 1m lands on each minute (09:00:00, 09:01:00, etc.), 1h on the hour (09:00, 10:00, etc.). Set round_interval = false under [agent] to start the first window when the agent starts without snapping (e.g. 09:25:12, then 10:25:12, etc.).
A live notification is useful when a health alarm is rare. It becomes noise when the same alarm keeps starting and clearing through rain or snow. We will add a limit so that a flickering Cause stops filling the notification queue, while the detection itself stays on.
Each Cause is counted on its own. The first few activations still notify you, and so do the alarm clears that belong to them. Once the same Cause has fired more than five times without an hour of quiet in between, one higher-priority notification will be sent that warns that further notifications for that Cause are being paused. After that, more activations and clears of that Cause are not sent. A different Cause keeps notifying as usual.
We will use the same cumulative_sum processor that we used to create the incrementing index. The difference this time is that we will add the option expiry_interval = "${ALARM_QUIET_PERIOD:-1h}". This will reset the counter after a configurable period of silence (with a default of one hour). This is what makes the alarm notifications turn back on again when the bad weather is over.
In the same way as before, we need to add a static number to the messages that the accumulator can sum for us:
[[processors.defaults]]
namepass = ["health_event_activated", "health_event_deactivated"]
[processors.defaults.fields]
incident = 1One non-obvious trick we will need to use is a regular dummy message that we will call health_event_expiry_tick. This is needed since the removing of silent alarms is done after the message is processed. The only purpose of this tick message is to trigger the cumulative_sum plugin so that it will evaluate the expiry_interval option and reset any silent alarm Causes.
[[inputs.mock]]
name_override = "health_event_expiry_tick"
interval = "1s"
[[inputs.mock.constant]]
name = "tick"
value = 1We can now add the actual counter:
[[processors.cumulative_sum]]
namepass = ["health_event_activated", "health_event_deactivated", "health_event_expiry_tick"]
fields = ["incident"]
expiry_interval = "${ALARM_QUIET_PERIOD:-1h}"After this, we have the incident_sum field on all messages that tells us how many times they have been repeated in this current burst. We can use that to trigger a new alert when alarms are being muted:
[[processors.clone]]
namepass = ["health_event_activated"]
metricpass = "fields.incident_sum == ${NOTIFY_MAX_BEFORE_PAUSE:-5} + 1"
name_override = "health_event_notifications_paused"This clone processor will create a new message called health_event_notifications_paused when an alarm is repeated for the sixth time in a burst.
We can also create two new messages called health_event_activated_notify and health_event_deactivated_notify that are only created if the alarm has not been repeated too many times in the burst:
[[processors.clone]]
namepass = ["health_event_activated"]
metricpass = "fields.incident_sum <= ${NOTIFY_MAX_BEFORE_PAUSE:-5}"
name_override = "health_event_activated_notify"
[[processors.clone]]
namepass = ["health_event_deactivated"]
metricpass = "fields.incident_sum <= ${NOTIFY_MAX_BEFORE_PAUSE:-5}"
name_override = "health_event_deactivated_notify"These three messages are now ready to use in the HTTP output to send push notifications.
The first thing we will send is the (non muted) alarm-activated notifications. We can use the template output format to format the text message in the same way as we did before. We can also add headers affecting how the notification will look like, like a Priority = "high" header to show that it is important, a title using the Title = "Image health event" header and finally one or more tags that will render as icons in the notification with Tags = "camera".
[[outputs.http]]
namepass = ["health_event_activated_notify"]
url = "${NTFY_TOPIC_URL}"
method = "POST"
timeout = "10s"
data_format = "template"
use_batch_format = false
metric_batch_size = 1
template = '{{ .Tag "Cause" }} alarm activated ({{ .Field "incident_sum" }} times)'
[outputs.http.headers]
Content-Type = "text/plain; charset=utf-8"
Title = "Image health event"
Tags = "camera"
Priority = "high"We then send our alarm-cleared notification in the same way as before, the only difference is that we are using the rate limited health_event_deactivated_notify message instead of the Any-Active-Events message. Since the former is already split and only include the active = false messages, we do not need the || fields.active == true part of the expression anymore. We use Priority = "default" for this informational notification.
[[outputs.http]]
namepass = ["health_event_deactivated_notify"]
metricpass = "fields.state_change_sum > 1"
url = "${NTFY_TOPIC_URL}"
method = "POST"
timeout = "10s"
data_format = "template"
use_batch_format = false
metric_batch_size = 1
template = "Image health is no longer alarming"
[outputs.http.headers]
Content-Type = "text/plain; charset=utf-8"
Title = "Image health event"
Tags = "camera"
Priority = "default"Next, we create a formatter for the alarm paused notifications. We use Priority = "max" and Tags = "camera,warning" to highlight the importance of knowing that further alarms will not be reported from this burst.
[[outputs.http]]
namepass = ["health_event_notifications_paused"]
url = "${NTFY_TOPIC_URL}"
method = "POST"
timeout = "10s"
data_format = "template"
use_batch_format = false
metric_batch_size = 1
template = '{{ .Tag "Cause" }} alarm notifications paused due to flickering'
[outputs.http.headers]
Content-Type = "text/plain; charset=utf-8"
Title = "Image health notifications paused"
Tags = "camera,warning"
Priority = "max"The final solution is a simple direct-to-cloud notification system for the AXIS Image Health Analytics monitoring with configurable values for regular reports and alarm rate limiting. Deploying the solution is only a few steps:
Make sure that you camera has the AXIS Image Health Analytics app and that it is running with enabled use cases.
Go to the ntfy web app and subscribe to a new topic. Copy the URL from the example text (e.g. https://ntfy.sh/my-event-topic).
Install and activate the FixedIT Data Agent ACAP app in your camera.
Download the complete configuration file.
Go to Configuration→Files in the FixedIT Data Agent web UI and press "Disable" next to the "Bundled config files".
Press "Upload Config" and select the configuration file you just downloaded.
Press "Enable" next to the configuration file.
Go to Configuration→Variables, press the plus icon under "Extra Telegraf variables" and add a new variable with the name NTFY_TOPIC_URL and set the value to the topic URL that you copied in step 1.
That's all. Optionally, you can add new variables to change the durations and event limits. Do this in the same way as in the last step but add a variable with name ALARM_QUIET_PERIOD and e.g. value 1h, name NOTIFY_MAX_BEFORE_PAUSE and e.g. value 2, and STATS_PERIOD with e.g. value 24h.
