mirror of
https://github.com/optim-enterprises-bv/siembol.git
synced 2025-11-02 11:28:15 +00:00
* grafana and prometheus * updated storm to latest * grafana and prometheus * grafana and prometheus * grafana and prometheus * grafana and prometheus * version * kafka lag exporter * include kafka lag * log level and change interval for scraping * update to use values.yaml file * fix * added latency graphs * added latency graphs, fix * added monitoring to clean up * using official docker image * remove outdated comment * fix, indentation * clean up * host names added * rename and clean up * rename and clean up * tag * jmx exporter cm added * jmx exporter cm added * jmx exporter volume mount * jmx exporter install * storm version * add jmx to ps * fix for changing port * add wget to install * not needed, we're using ingress-dns add on and configuring actual dns resolver * fix * fix post request * add protection matches to dashboard * separate traffic generator from main siembol install * update * update * move file to correct loc * typo * fix Co-authored-by: Yassin Raman <yassin@gmail.co> Co-authored-by: yasram1 <yasram1@github.com> Co-authored-by: Celie Valentiny <cvalentiny@hotmail.fr>
29 lines
861 B
Python
29 lines
861 B
Python
from kafka import KafkaProducer
|
|
import os
|
|
import time
|
|
import json
|
|
|
|
topic = os.getenv('KAFKA_TOPIC')
|
|
message_key = os.getenv('MESSAGE_KEY')
|
|
frequency_per_second = int(os.getenv('MESSAGE_FREQUENCY_PER_SECOND'))
|
|
demo_messages_file = os.getenv('DEMO_MESSAGES_FILE')
|
|
|
|
with open(demo_messages_file, "r") as f:
|
|
messages = json.load(f)
|
|
|
|
message = messages.get(message_key)
|
|
if message is None:
|
|
raise Exception(f'Message not found in json: key {message_key} not found')
|
|
|
|
producer = KafkaProducer(bootstrap_servers=os.getenv('KAFKA_SERVERS'))
|
|
count = 0
|
|
start_time = time.time()
|
|
while True:
|
|
producer.send(topic, str.encode(message))
|
|
count += 1
|
|
if count%frequency_per_second == 0:
|
|
print(f'Sent {count} messages to topic {topic}')
|
|
end_time = time.time()
|
|
time.sleep(max(1-(end_time - start_time), 0))
|
|
start_time += 1
|