Skip to content

Commit

Permalink
Poll for alerts data #158
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Jan 24, 2023
1 parent 75354e1 commit 246ea5d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
11 changes: 11 additions & 0 deletions telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
date_format = "2006"
timezone = "America/Los_Angeles"

# Alert Data
[[inputs.http]]
urls = [
"http://pypowerwall:8675/alerts/pw"
]
name_override = "alerts"
method = "GET"
insecure_skip_verify = true
timeout = "4s"
data_format = "json"

# Configuration for sending metrics to InfluxDB
#[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
Expand Down
31 changes: 30 additions & 1 deletion telegraf.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,33 @@
# timeout = "4s"
# data_format = "json"
# json_query = "0.Cached_readings"
# fieldpass = ["instant_power", "real_power_?", "energy_??ported"]
# fieldpass = ["instant_power", "real_power_?", "energy_??ported"]

# Example starlark processor using to rewrite alert data to new_alert (1) and
# remember alerts even if they disappear (0) - see Issue #158
#
# [[processors.starlark]]
# source = '''
# state = {
# "last": {}
# }
# def dict_union(x, y):
# z = {}
# z.update(x)
# z.update(y)
# return z
# def apply(metric):
# url = metric.tags.get("url")
# last = state["last"]
# if url and url == "http://pypowerwall:8675/alerts/pw":
# base = {x: 0 for x in metric.fields.keys()} #For updating existing total key set
# current = {x: 1 for x in metric.fields.keys()} #Currently flagging keys
# result = dict_union(last,current)
# state["last"] = dict_union(last, base)
# new_metric = Metric("all_alerts")
# for k, v in result.items():
# new_metric.fields[str(k)] = v
# return new_metric
# else:
# return metric
# '''

0 comments on commit 246ea5d

Please sign in to comment.