Skip to content

Commit

Permalink
chg: [zmq_to_influx] Added .env variable to select which bucket the d…
Browse files Browse the repository at this point in the history
…ata should be pushed to
  • Loading branch information
mokaddem committed Mar 15, 2024
1 parent f16e005 commit 4a166d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
INFLUXDB_URL=http://localhost:8086
INFLUXDB_TOKEN=tokentokentoken
INFLUXDB_ORG=org
MISP_ZMQ_URL=tcp://localhost:50000
INFLUXDB_BUCKET=misp
MISP_ZMQ_URL=tcp://localhost:50000
12 changes: 6 additions & 6 deletions src/push_zmq_to_influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def push_metric(api, instance, topic, m, recv_ts):
if topic == "misp_json_audit" and "AuditLog" in m:
logging.info("AuditLog pushed to InfluxDB")
api.write(bucket="misp", record={
api.write(bucket=os.getenv("INFLUXDB_BUCKET"), record={
"measurement": "audit",
"tags": {
"model": m["AuditLog"]["model"].lower(),
Expand Down Expand Up @@ -58,7 +58,7 @@ def push_metric(api, instance, topic, m, recv_ts):
},
}

api.write(bucket="misp", record=r)
api.write(bucket=os.getenv("INFLUXDB_BUCKET"), record=r)

if topic == "misp_json_event" and "Event" in m:
logging.info("Event pushed to InfluxDB")
Expand All @@ -78,11 +78,11 @@ def push_metric(api, instance, topic, m, recv_ts):
r["fields"]["org"] = m["Orgc"].get("name", "")
r["fields"]["org_id"] = m["Orgc"].get("id", "")

api.write(bucket="misp", record=r)
api.write(bucket=os.getenv("INFLUXDB_BUCKET"), record=r)

if topic == "misp_json_attribute" and "Attribute" in m:
logging.info("Attribute pushed to InfluxDB")
api.write(bucket="misp", record={
api.write(bucket=os.getenv("INFLUXDB_BUCKET"), record={
"measurement": "attribute",
"tags": {
"category": m["Attribute"].get("category", "").lower(),
Expand All @@ -101,7 +101,7 @@ def push_metric(api, instance, topic, m, recv_ts):

if topic == "misp_json_sighting" and "Sighting" in m:
logging.info("Sighting pushed to InfluxDB")
api.write(bucket="misp", record={
api.write(bucket=os.getenv("INFLUXDB_BUCKET"), record={
"measurement": "sighting",
"tags": {
"category": m["Attribute"].get("category", "").lower(),
Expand All @@ -121,7 +121,7 @@ def push_metric(api, instance, topic, m, recv_ts):

if topic == "misp_json_self" and "status" in m:
logging.info("ZMQ status pushed to InfluxDB")
api.write(bucket="misp", record={
test = api.write(bucket=os.getenv("INFLUXDB_BUCKET"), record={
"measurement": "zmq_status",
"tags": {
"instance": instance
Expand Down

0 comments on commit 4a166d5

Please sign in to comment.