Note: This is a sample/example program designed to demonstrate integration between Cisco Intersight and Apache Kafka. It is provided as a reference implementation and not intended for production use without additional hardening, testing, and security review.
A Python-based event poller that fetches alarms and audit logs from Cisco Intersight and streams them to Apache Kafka topics for downstream consumption.
localhost:9092 (can be configured)cd /path/to/kafka-intersight # Create and activate virtual environment python3 -m venv .venv source .venv/bin/activate # Install dependencies pip install -r requirements.txt
Copy the example file and fill in your Intersight credentials:
cp .env.example .env
Edit .env and set:
INTERSIGHT_KEY_ID: Your Intersight API key IDINTERSIGHT_SECRET_KEY_FILE: Path to your private key file (default: .secretkey)INTERSIGHT_ENDPOINT: Intersight API endpoint (default: https://intersight.com)Optional tuning variables (defaults are safe):
LOG_LEVEL: INFO (default) or DEBUGDELIVERY_TIMEOUT_SECONDS: 10.0 (default)RETRY_BASE_SECONDS: 2.0 (default)RETRY_MAX_SECONDS: 60.0 (default)RETRY_JITTER_SECONDS: 1.0 (default)COLD_START_MINUTES: 5 (default, how far back to look on first run)brew install kafka
zkServer start
You should see:
ZooKeeper server started.
In a new terminal:
kafka-server-start /opt/homebrew/etc/kafka/server.properties
You should see:
[main] INFO kafka.server.KafkaServer - started (kafka.server.KafkaServer)
Verify Kafka is listening:
lsof -i :9092
Should show the Kafka process listening on port 9092.
Activate the virtual environment (if not already active):
source .venv/bin/activateStart the poller:
.venv/bin/python kafka-intersight.py
You should see logs like:
2026-04-03 14:10:20,123 INFO kafka-intersight poller-started endpoint=https://intersight.com kafka_bootstrap=['localhost:9092'] delivery_timeout_s=10.0 retry_base_s=2.0 retry_max_s=60.0
2026-04-03 14:10:21,456 INFO kafka-intersight poll-start topic=intersight-alarms since=2026-04-03T14:05:20.123Z
2026-04-03 14:10:22,789 INFO kafka-intersight poll-start topic=intersight-audits since=2026-04-03T14:05:20.123Z
2026-04-03 14:10:23,012 INFO kafka-intersight run-summary alarms_published=5 audits_published=12 alarms_fetched=5 audits_fetched=12
2026-04-03 14:10:23,034 INFO kafka-intersight metrics-total fetched=17 published=17 delivery_failed=0
2026-04-03 14:10:23,045 INFO kafka-intersight poll-success next_poll_seconds=60
The poller starts a continuous loop polling Intersight every 60 seconds (default POLL_INTERVAL).
To stop the poller, press Ctrl+C.
kafka-topics --bootstrap-server localhost:9092 --list
You should see:
intersight-alarms
intersight-audits
To see all alarms ever published to the topic:
kafka-console-consumer \ --bootstrap-server localhost:9092 \ --topic intersight-alarms \ --from-beginning
To see all audits:
kafka-console-consumer \ --bootstrap-server localhost:9092 \ --topic intersight-audits \ --from-beginning
Press Ctrl+C to stop consuming.
To see only new messages as they arrive (no backlog):
kafka-console-consumer \ --bootstrap-server localhost:9092 \ --topic intersight-alarms
Run this in a terminal, then run the poller in another terminal. New messages will appear in the consumer.
kafka-console-consumer \
--bootstrap-server localhost:9092 \
--topic intersight-alarms \
--from-beginning \
--property print.key=true \
--property print.timestamp=true \
--property key.separator=" | "Output example:
alarm-moid-123 | 1712152200000 | {"moid":"alarm-moid-123","create_time":"2026-04-03T14:10:00Z",...}
alarm-moid-456 | 1712152260000 | {"moid":"alarm-moid-456","create_time":"2026-04-03T14:11:00Z",...}
jqIf you have jq installed:
kafka-console-consumer \ --bootstrap-server localhost:9092 \ --topic intersight-alarms \ --from-beginning | jq .
Output example:
{
"moid": "alarm-moid-123",
"create_time": "2026-04-03T14:10:00Z",
"acknowledge_time": null,
"status": "active"
}kafka-topics --bootstrap-server localhost:9092 --describe --topic intersight-alarms
Output:
Topic: intersight-alarms TopicId: xxxxx PartitionCount: 1 ReplicationFactor: 1 Configs:
Topic: intersight-alarms Partition: 0 Leader: 0 Replicas: 0 Isr: 0
kafka-run-class kafka.tools.JmxTool \ --object-name kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec \ --reporting-interval 1000 \ --attributes Count
Alternatively, consume all messages and count:
kafka-console-consumer \
--bootstrap-server localhost:9092 \
--topic intersight-alarms \
--from-beginning \
--max-messages 1000 | wc -lIn the Kafka terminal, press Ctrl+C or:
kafka-server-stop
Stop Zookeeper:
zkServer stop
| Variable | Default | Description |
|---|---|---|
INTERSIGHT_KEY_ID |
Required | Intersight API key ID |
INTERSIGHT_SECRET_KEY_FILE |
.secretkey |
Path to Intersight private key file |
INTERSIGHT_ENDPOINT |
https://intersight.com |
Intersight API endpoint |
LOG_LEVEL |
INFO |
Logging level: INFO, DEBUG, WARNING, ERROR |
DELIVERY_TIMEOUT_SECONDS |
10.0 |
Kafka message delivery confirmation timeout |
RETRY_BASE_SECONDS |
2.0 |
Base delay for exponential backoff on transient errors |
RETRY_MAX_SECONDS |
60.0 |
Maximum delay for backoff |
RETRY_JITTER_SECONDS |
1.0 |
Random jitter added to backoff delay |
COLD_START_MINUTES |
5 |
How far back to look on first run (minutes) |
BOOTSTRAP_SERVERS |
localhost:9092 |
Kafka broker(s) (set in code, not .env) |
POLL_INTERVAL |
60 |
Poll frequency in seconds (set in code, not .env) |
The poller classifies errors and responds accordingly:
RETRY_MAX_SECONDS.lsof -i :9092LOG_LEVEL=DEBUG..envgrep -i "unauthorized\|invalid\|401" <logfile>COLD_START_MINUTES)lsof -i :9092--timeout-ms 5000 to prevent infinite waitkafka-server-start /opt/homebrew/etc/kafka/server.propertieslsof -i :9092To enable debug logging:
LOG_LEVEL=DEBUG .venv/bin/python kafka-intersight.py
To adjust retry/timeout settings:
RETRY_BASE_SECONDS=1.0 RETRY_MAX_SECONDS=30.0 DELIVERY_TIMEOUT_SECONDS=5.0 \ .venv/bin/python kafka-intersight.py ```Example/Sample Status This is a **reference implementation** and sample program. It demonstrates: - Loading credentials from environment variables - Calling the Intersight API with authentication - Publishing to Kafka topics - Error classification and retry strategies - Structured logging **Before production use**, consider: - Adding persistence for checkpoints (database, Redis, etc.) - Implementing comprehensive monitoring and alerting - Adding secrets management (Vault, Secrets Manager, etc.) - Conducting security audits and penetration testing - Performance testing under expected load - Adding integration and end-to-end tests - Setting up proper backup and disaster recovery procedures
Owner
Contributors
Categories
Data CenterProducts
IntersightLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community