rsyslog/tests/mmaitag-invalid-key.sh
Rainer Gerhards fb51433919
feat: introduce mmaitag PoC with Gemini AI provider (#5754)
This commit adds the initial implementation of the `mmaitag` module,
a pluggable AI-based message classification processor.

The module supports two providers:
- `gemini`: uses the Gemini API via libcurl and JSON-C
- `gemini_mock`: a deterministic in-memory mock used for testing

Each log message is classified individually and tagged with a label
stored in a configurable message variable (default: `$.aitag`).

Included:
- Provider abstraction layer (`ai_provider.h`)
- Gemini provider with API key support (inline or via file)
- Prompt customization and input property selection
- Two regression tests: basic and invalid-key scenarios
- Sphinx documentation under `doc/configuration/modules`

Note: mmaitag is in its infancy and primarily a PoC. Future work
will improve batching, performance, and add more providers.

Refs:
- https://github.com/rsyslog/rsyslog/issues/5747 (AI-first strategy)

With the help of AI Agents: Codex, Gemini
2025-07-15 17:33:07 +02:00

24 lines
649 B
Bash
Executable File

#!/bin/bash
## test gemini provider with invalid API key
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
module(load="../plugins/mmaitag/.libs/mmaitag")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
template(name="outfmt" type="string" string="%msg% [%$.aitag%]\n")
if($msg contains "msgnum:00") then {
action(type="mmaitag" provider="gemini" apikey="dummy")
}
action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
'
startup
tcpflood -m 1
shutdown_when_empty
wait_shutdown
content_check "request for a message failed" "$RSYSLOG_OUT_LOG"
exit_test