Commit graph

2381 commits

Author SHA1 Message Date
dependabot[bot]
6b99cab172
build(deps): bump github.com/redis/go-redis/v9 in /tests
Bumps [github.com/redis/go-redis/v9](https://github.com/redis/go-redis) from 9.17.0 to 9.17.1.
- [Release notes](https://github.com/redis/go-redis/releases)
- [Changelog](https://github.com/redis/go-redis/blob/master/RELEASE-NOTES.md)
- [Commits](https://github.com/redis/go-redis/compare/v9.17.0...v9.17.1)

---
updated-dependencies:
- dependency-name: github.com/redis/go-redis/v9
  dependency-version: 9.17.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-26 18:19:11 +00:00
Alvar
76e3a45a7a
Merge pull request #1041 from Icinga/dependabot/go_modules/tests/github.com/redis/go-redis/v9-9.17.0
Some checks failed
Build and Publish Container Image / build-and-publish-container-image (push) Has been cancelled
Go / build-test (macos-latest) (push) Has been cancelled
Go / build-test (ubuntu-latest) (push) Has been cancelled
Go / lint (push) Has been cancelled
Go / vet (push) Has been cancelled
Go / fmt (push) Has been cancelled
Go / modtidy (push) Has been cancelled
Go / vendor-diff (push) Has been cancelled
Integration Tests / MySQL (push) Has been cancelled
Integration Tests / PostgreSQL (push) Has been cancelled
SQL / MySQL 5.5 (push) Has been cancelled
SQL / MySQL 5.6 (push) Has been cancelled
SQL / MariaDB 10.1 (push) Has been cancelled
SQL / MariaDB 10.2 (push) Has been cancelled
SQL / MariaDB 10.3 (push) Has been cancelled
SQL / MariaDB 10.4 (push) Has been cancelled
SQL / MariaDB 10.5 (push) Has been cancelled
SQL / MariaDB 10.6 (push) Has been cancelled
SQL / MariaDB 10.7 (push) Has been cancelled
SQL / MariaDB latest (push) Has been cancelled
SQL / MySQL 5.7 (push) Has been cancelled
SQL / MySQL 8 (push) Has been cancelled
SQL / MySQL latest (push) Has been cancelled
SQL / PostgreSQL 10 (push) Has been cancelled
SQL / PostgreSQL 11 (push) Has been cancelled
SQL / PostgreSQL 12 (push) Has been cancelled
SQL / PostgreSQL 13 (push) Has been cancelled
SQL / PostgreSQL 9.6 (push) Has been cancelled
SQL / PostgreSQL latest (push) Has been cancelled
Sync For-Container.md to Docker Hub / sync (push) Has been cancelled
build(deps): bump github.com/redis/go-redis/v9 from 9.16.0 to 9.17.0 in /tests
2025-11-21 08:49:41 +00:00
dependabot[bot]
20a9361c73
build(deps): bump github.com/redis/go-redis/v9 in /tests
Bumps [github.com/redis/go-redis/v9](https://github.com/redis/go-redis) from 9.16.0 to 9.17.0.
- [Release notes](https://github.com/redis/go-redis/releases)
- [Changelog](https://github.com/redis/go-redis/blob/master/RELEASE-NOTES.md)
- [Commits](https://github.com/redis/go-redis/compare/v9.16.0...v9.17.0)

---
updated-dependencies:
- dependency-name: github.com/redis/go-redis/v9
  dependency-version: 9.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-21 08:37:28 +00:00
Alvar
ba8788854a
Merge pull request #1044 from Icinga/dependabot/github_actions/actions/checkout-6
build(deps): bump actions/checkout from 5 to 6
2025-11-21 08:35:01 +00:00
Alvar
f02deb3bdf
Merge pull request #1043 from Icinga/dependabot/go_modules/tests/go.uber.org/zap-1.27.1
build(deps): bump go.uber.org/zap from 1.27.0 to 1.27.1 in /tests
2025-11-21 08:34:41 +00:00
Alvar
da445ce3c6
Merge pull request #1042 from Icinga/dependabot/go_modules/go.uber.org/zap-1.27.1
build(deps): bump go.uber.org/zap from 1.27.0 to 1.27.1
2025-11-21 08:34:33 +00:00
dependabot[bot]
6d361f1e11
build(deps): bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-20 18:11:35 +00:00
dependabot[bot]
4888fbbfd3
build(deps): bump go.uber.org/zap from 1.27.0 to 1.27.1 in /tests
Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.27.0 to 1.27.1.
- [Release notes](https://github.com/uber-go/zap/releases)
- [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/zap/compare/v1.27.0...v1.27.1)

---
updated-dependencies:
- dependency-name: go.uber.org/zap
  dependency-version: 1.27.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-20 18:07:19 +00:00
dependabot[bot]
528efbd72c
build(deps): bump go.uber.org/zap from 1.27.0 to 1.27.1
Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.27.0 to 1.27.1.
- [Release notes](https://github.com/uber-go/zap/releases)
- [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uber-go/zap/compare/v1.27.0...v1.27.1)

---
updated-dependencies:
- dependency-name: go.uber.org/zap
  dependency-version: 1.27.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-20 18:00:55 +00:00
Julian Brost
4996989b31
Merge pull request #1035 from Icinga/release-1.5.0
Some checks failed
Build and Publish Container Image / build-and-publish-container-image (push) Has been cancelled
Go / build-test (macos-latest) (push) Has been cancelled
Go / build-test (ubuntu-latest) (push) Has been cancelled
Go / lint (push) Has been cancelled
Go / vet (push) Has been cancelled
Go / fmt (push) Has been cancelled
Go / modtidy (push) Has been cancelled
Go / vendor-diff (push) Has been cancelled
Integration Tests / MySQL (push) Has been cancelled
Integration Tests / PostgreSQL (push) Has been cancelled
SQL / MySQL 5.5 (push) Has been cancelled
SQL / MySQL 5.6 (push) Has been cancelled
SQL / MariaDB 10.1 (push) Has been cancelled
SQL / MariaDB 10.2 (push) Has been cancelled
SQL / MariaDB 10.3 (push) Has been cancelled
SQL / MariaDB 10.4 (push) Has been cancelled
SQL / MariaDB 10.5 (push) Has been cancelled
SQL / MariaDB 10.6 (push) Has been cancelled
SQL / MariaDB 10.7 (push) Has been cancelled
SQL / MariaDB latest (push) Has been cancelled
SQL / MySQL 5.7 (push) Has been cancelled
SQL / MySQL 8 (push) Has been cancelled
SQL / MySQL latest (push) Has been cancelled
SQL / PostgreSQL 10 (push) Has been cancelled
SQL / PostgreSQL 11 (push) Has been cancelled
SQL / PostgreSQL 12 (push) Has been cancelled
SQL / PostgreSQL 13 (push) Has been cancelled
SQL / PostgreSQL 9.6 (push) Has been cancelled
SQL / PostgreSQL latest (push) Has been cancelled
Sync For-Container.md to Docker Hub / sync (push) Has been cancelled
Release Icinga DB Version 1.5.0
2025-11-18 15:59:03 +01:00
Alvar Penning
2666c6c14d
Release Icinga DB Version 1.5.0 2025-11-18 09:22:52 +01:00
Julian Brost
ff1c49e63f
Merge pull request #998 from Icinga/icinga-notifications-init
Some checks are pending
Build and Publish Container Image / build-and-publish-container-image (push) Waiting to run
Go / build-test (macos-latest) (push) Waiting to run
Go / build-test (ubuntu-latest) (push) Waiting to run
Go / lint (push) Waiting to run
Go / vet (push) Waiting to run
Go / fmt (push) Waiting to run
Go / modtidy (push) Waiting to run
Go / vendor-diff (push) Waiting to run
Integration Tests / MySQL (push) Waiting to run
Integration Tests / PostgreSQL (push) Waiting to run
SQL / MySQL 5.5 (push) Waiting to run
SQL / MySQL 5.6 (push) Waiting to run
SQL / MariaDB 10.1 (push) Waiting to run
SQL / MariaDB 10.2 (push) Waiting to run
SQL / MariaDB 10.3 (push) Waiting to run
SQL / MariaDB 10.4 (push) Waiting to run
SQL / MariaDB 10.5 (push) Waiting to run
SQL / MariaDB 10.6 (push) Waiting to run
SQL / MariaDB 10.7 (push) Waiting to run
SQL / MariaDB latest (push) Waiting to run
SQL / MySQL 5.7 (push) Waiting to run
SQL / MySQL 8 (push) Waiting to run
SQL / MySQL latest (push) Waiting to run
SQL / PostgreSQL 10 (push) Waiting to run
SQL / PostgreSQL 11 (push) Waiting to run
SQL / PostgreSQL 12 (push) Waiting to run
SQL / PostgreSQL 13 (push) Waiting to run
SQL / PostgreSQL 9.6 (push) Waiting to run
SQL / PostgreSQL latest (push) Waiting to run
Sync For-Container.md to Docker Hub / sync (push) Waiting to run
Initial Icinga Notifications Source
2025-11-17 13:46:42 +01:00
Alvar Penning
327862c4f2
Rename notifications-source to notifications
Drop the "-source" suffix from the configuration option. Furhtermore,
with the latest IGL release 0.8.1[0], the "api-base-url" is renamed to
just "url".

[0]: https://github.com/Icinga/icinga-go-library/pull/168
2025-11-17 09:22:37 +01:00
Alvar Penning
e8c0359c4e
doc: Update for Notifications
Remove the generic information from 01-About.md and add a warning to
03-Configuration.md that this feature might not be stable.
2025-11-17 09:20:07 +01:00
Alvar Penning
f8c2ab4b17
notifications: Speed up StreamSorter Tests
Allow configurable timeouts for the StreamSorter, to set them to a
fraction of their default for the tests. Now the tests are done in three
seconds instead of three minutes.

While doing so, another race condition with the test logging was
unveiled. Since this race results from a closing test context and test
logger, there was not much to do and I decided to just drop the logging
message, which was used only for tests anyway.
2025-11-17 09:20:07 +01:00
Alvar Penning
2a5fde1594
notifications: Mute and Unmute Events
Populate the Event's Mute field for muting and unmuting for flapping
events and acknowledgements.
2025-11-17 09:20:07 +01:00
Alvar Penning
46b1c6d673
notifications: TypeAcknowledgementCleared Message
Change the message for TypeAcknowledgementCleared events to a more
obvious one.
2025-11-17 09:20:07 +01:00
Alvar Penning
e012ef6d1b
notifications: Import StreamSorter Logic
The whole StreamSorter logic is only required for Icinga Notifications.
Thus, the implementation was moved from the history package to the
notifications package, removing some unnecessary generalizations on the
way. This results in big changes to be made in the notifications
package, while other modules are mostly not affected.
2025-11-17 09:20:07 +01:00
Alvar Penning
c6368b1f82
notifications.Client: Allow Parameters of any Type
The parameters can not only be strings, but anything to PHP's liking. In
one example, an integer was observed. Since Parameters is converted to
an []any later anyways, this is no real change in behavior.
2025-11-17 09:20:07 +01:00
Alvar Penning
0cd4978419
history.StreamSorter: Few comments, No Data Races
After Julian reworked big parts of the StreamSorter for the better, I
went over the code multiple times and added a few comments for parts I
had to read twice.

Within the tests, there might be a data race when zaptest is used after
the test's context is done. Since there were a few log messages
potentially occurring after the test's end, a guard was added to ensure
no verbose log messages are being produced if the context is done.
2025-11-17 09:20:07 +01:00
Julian Brost
6569487fbb
StreamSorter: improve output channel close behavior and simplify implementation
This commit is pretty much an overhaul of the implementation to allow for a
more straight-forward way to close the output channel. The main changes to the
implementation are:

- StreamSorter now provides a method PipelineFunc that can directly be used in
  a history sync pipeline. This allows StreamSorter to handle the in + out
  stream pair internally, so that it closes out after in was closed and all
  messages from it were passed to out.
- The two worker goroutines were combined into a single one and the secondary
  queue was removed. All pending messages remain in the heap and will only be
  removed from the heap when they are about to be passed to the callback.
- The worker now handles all operations (send and close) on the output stream.
2025-11-17 09:20:07 +01:00
Alvar Penning
18518cf813
history.streamSorterSubmissions: Use Pointer
Next to some other small cleanups, the streamSorterSubmissions slice
type now references pointers.
2025-11-17 09:20:07 +01:00
Alvar Penning
3e4f05d9fd
notifications: Fix flat customvars
Next to minor changes, the custom variables are now fetched from
customvar_flat, being in their flat format.
2025-11-17 09:20:07 +01:00
Alvar Penning
d97e1624dc
telemetry: Remove leftover Stats.Callback
Seems to be forgotten in e475a5ef91.
2025-11-17 09:20:07 +01:00
Alvar Penning
b61b0ab279
history.StreamSorter: Cleanup Output Channel
Introduce the StreamSorter.CloseOutput method to remove all submissions
for a certain output channel from both workers before closing the
channel.

The motivation behind this change is to have a single point where the
output channel is closed while no submissions are being sent into an
already closed channel.
2025-11-17 09:20:07 +01:00
Alvar Penning
9dee483ed1
history.StreamSorter: Various Fixes
- Store the streamSorterSubmission submission time as a time.Time
  instead of a nanosecond timestamp, comparing the time.Timer's
  monotonic clock.
- Replace time-based buckets in StreamSorter.submissionWorker by a heap
  to be pushed and popped. However, only submissions of a certain age
  are being forwarded. Reduces complexity quite a bit.
- Reduce complexity of StreamSorter.queueWorker by getting rid of
  unnecessary channel signals by checking for new queue events for
  processing at the loop start.
2025-11-17 09:20:07 +01:00
Alvar Penning
1c2e14a5e2
history.parseRedisStreamId: Remove regex
With parseRedisStreamId being in the "hot path", the quite simple
regular expression was exchanged with an even simpler string split.
However, as network operations precede and follow this, the benefit of
this optimization might be questionable.
2025-11-17 09:20:07 +01:00
Alvar Penning
45877e72a3
telemetry: Undo Stats rework
Effectively reverting cf4bd92611 and
passing a pointer to the relevant com.Counter to the history sync.
2025-11-17 09:20:07 +01:00
Alvar Penning
a8ff0a23e5
notifications: Simplify Icinga DB Web Rule Evaluation
- Ignore the "config" part of the JSON struct which is only relevant for
  Icinga DB Web.
- Remove unnecessary string conversions.
- Small code changes/improvements.
2025-11-17 09:20:07 +01:00
Alvar Penning
8baa5e7f5a
history: SyncCallbackConf For Common Callback Conf
Refactor multiple variables into common struct to ease handling.
2025-11-17 09:20:07 +01:00
Alvar Penning
aa83338786
config.example.yml: Reformat notifications-source 2025-11-17 09:20:07 +01:00
Alvar Penning
ebcdadbd44
notifications: Custom Vars From SQL, Output Format
Rework the prior custom variable fetching code to no longer fetch
everything in a looping fashion from Redis, but send SQL queries for
custom variables now.

In addition, for service objects now contain both the service and host
custom variables, prefixed by "host.vars." or "service.vars.".
2025-11-17 09:20:07 +01:00
Alvar Penning
4a4792dfee
history: StreamSorter for Notifications Callback
The StreamSorter was added to history, allowing to collect messages from
multiple Redis streams, sorting them based on the timestamp in the
Stream ID, and ejecting them back.

This is used for the callback stage, required by Icinga Notification. In
the Notification context, an ordered stream is required.

Despite my best intention, it felt like I have created an Erlang.
2025-11-17 09:20:07 +01:00
Alvar Penning
b8e11b390e
notifications: Evaluate Icinga DB Web Rule Filter
The rules are no longer just plain SQL queries, but have now their own
JSON format, introduced by Icinga DB Web. This format is now supported
by Client.evaluateRulesForObject.

- https://github.com/Icinga/icingadb-web/pull/1289
- https://github.com/Icinga/icingadb/pull/998#issuecomment-3442298348
2025-11-17 09:20:07 +01:00
Alvar Penning
5abb8b4212
notifications: Fetch customvars from Redis
After reintroducing Event.ExtraTags in the IGL and Icinga Notifications,
Icinga DB populates events by their custom variables.

At the moment, the required customvars are fetched from Redis for each
event. Due to the Redis schema, at least on HGETALL with manual
filtering is required. This might be a good candidate for further
caching, and cache invalidation.
2025-11-17 09:20:07 +01:00
Alvar Penning
1ec561415d
Minor Tweaks for Icinga Notifications Integration
- Don't validate notifications config in a background Goroutine.
- Clip pipeline slice to avoid reusing capability twice.
- Rework notification Client.buildCommonEvent and depending methods.
- Resubmit events after updating rules in one go.
- Simplify Client.fetchHostServiceName based on Julian's suggestion.

Co-Authored-By: Julian Brost <julian.brost@icinga.com>
2025-11-17 09:20:07 +01:00
Alvar Penning
ad26a7857d
Configurable callback sync telemetry stat name
Refactor the telemetry.Stats to allow custom names. This enabled dynamic
callback names for the Redis history sync, used by Icinga Notifications.
2025-11-17 09:20:07 +01:00
Alvar Penning
7ec28098f8
Document Notification Source
Briefly describe the required configuration for Icinga Notifications
Source next to mentioning it in the About section.
2025-11-17 09:20:07 +01:00
Alvar Penning
432db22f82
notifications: Reflect RulesInfo IGL update
The RulesInfo type was simplified. Rules are no longer a custom struct,
but just represented by the map key and a filter expression string.
2025-11-17 09:20:07 +01:00
Alvar Penning
30b5c45162
notifications: Don't abort for faulty object rules
When a faulty - like syntactical incorrect - object filter expression
was loaded, each evaluation fails. However, prior to this change, the
submission logic was exited, making Icinga DB unable to recover. Now,
the event will be considered as no rule has matched and new rule version
can be loaded.
2025-11-17 09:20:07 +01:00
Alvar Penning
37212a2b64
notifications: Send relative Icinga Web 2 URLs
There is no need to let each Icinga Notifications source know the root
URL of Icinga Web 2. Since the latest IGL and IN change, partly URLs
relative to Icinga Web 2 are supported.
2025-11-17 09:20:07 +01:00
Alvar Penning
b6e9b61b15
history: Retry failing callback submissions
Do not silently drop failing callback submissions - such as Icinga
Notification during restarts or network disruptions -, but switch the
internal makeCallbackStageFunc stageFunc into a backlog mode.

This resulted in multiple changes, including removing the background
worker for notifications.Client, as otherwise the event submission
status could not be propagated back.
2025-11-17 09:20:07 +01:00
Alvar Penning
3a7e1f4aff
notifications: IGL Changes For Rules
The rules and rule version is now part of the Event.

Also rename the Client method receiver variable.
2025-11-17 09:20:07 +01:00
Alvar Penning
697eca139d
Notifications: Address Code Review
- Bump IGL to latest changes in Icinga/icinga-go-library#145.
- Allow specifying which pipeline keys are relevant, ignore others.
- Allow specifying which pipeline key should be parsed in which type.
- Create history.DowntimeHistoryMeta as a chimera combining
  history.DowntimeHistory and history.HistoryDowntime to allow access
  event_type, distinguishing between downtime_start and downtime_end.
- Trace times for submission steps in the worker. Turns out, the single
  threaded worker blocks roughly two seconds for each
  Client.ProcessEvent method call. This might sum up to minutes if lots
  of events are processed at once. My current theory is that the delay
  results in the expensive bcrypt hash comparison on Notifications.
2025-11-17 09:20:07 +01:00
Yonas Habteab
49b7d98084
Drop superfluous rulesMutex
There won't be any concurrent access to the rules, so we don't need to
guard it with a mutex.
2025-11-17 09:20:07 +01:00
Yonas Habteab
7e5b8e5385
Retrieve host and service names from Redis
Instead of retrieving the host and service names from the used RDBMs,
this commit allows us to query them from Redis. This is done to avoid
the overhead of database queries, especially when the host and service
names are always to be found in Redis. The previous implementation
simply perfomed two database queries with each received entity based on
their IDs, but we can perform this operation more efficiently from Redis
using the same filtering logic as before. Of course, we now have to
maintain more code needed to handle the Redis operations, but this is a
trade-off we should be willing to make for performance reasons.
2025-11-17 09:20:07 +01:00
Yonas Habteab
ca3f7c5c9d
Reevaluate rules immediately after refetching them
Otherwise, posting the entity in a `go s.Submit(entity)`
manner in the background will mess up the order of events
as there might be another even in the queue affecting the
same entity.

Apart from that, the log entry "submitted event ..." is also
downgraded to debug level, as it creates too much noise at the
info level without saying anything relevant to an end user.
2025-11-17 09:20:07 +01:00
Yonas Habteab
f170f3763e
Don't limit queries referncing to {host,service}_id & Env ID params
Instead allow them to reference any columns of the database entity as
long as that entity provides it. It also removes the retry mechanism
used to execute the queries as this would block the worker
unnecessarily.
2025-11-17 09:20:07 +01:00
Yonas Habteab
95da9ee443
Use the newly introduced notifications event utils from igl
Most of the notifications related code from here were outsourced to
Icinga Go Library, thus removes all the now obsolte ones from here.
2025-11-17 09:20:07 +01:00
Alvar Penning
848807d96c
Initial Icinga Notifications Source
This is the first version to use Icinga DB as an event source for Icinga
Notifications. If configured accordingly, Icinga DB forwards events
crafted from the Redis pipeline to the Icinga Notifications API.

This required a small refactoring of the history synchronization to
allow hooking into the Redis stream. Afterwards, the newly introduced
notifications package handles the rest.

Note: As part of this architectural change, Icinga Notifications offers
filters to be evaluated by Icinga DB. At the moment, these are SQL
queries being executed on the Icinga DB relational database. Either
consider both Icinga DB and Icinga Notifications to be part of the same
trust domain or consider the security implications.

Furthermore, this change requires a change on Icinga Notifications as
well. This will not work with the current version 0.1.1.
2025-11-17 09:20:07 +01:00