Hi All
I am really breaking my head over how to setup parsing in telegraf. I am probably missing something stupid, but I am new so trial and error has unfortunately not been my friend.
I am trying to retrieve information from our local electrical loadshedding (blackouts) schedules. My expectation is that each line relates to the appropriate day (probably as a tag) with fields representing the various stages of load shedding, ie, ranging from stages 1 - 8. A copy of the HTTP request is below:
{
"events": [
{
"end": "2023-01-16T19:30:00+02:00",
"note": "Stage 8 (TESTING: current)",
"start": "2023-01-16T17:00:00+02:00"
}
],
"info": {
"name": "TESTING Honeydew (11)",
"region": "JHB City Power"
},
"schedule": {
"days": [
{
"date": "2023-01-16",
"name": "Monday",
"stages": [
[
"18:00-20:30"
],
[
"10:00-12:30",
"18:00-20:30"
],
[
"02:00-04:30",
"10:00-12:30",
"18:00-20:30"
],
[
"02:00-04:30",
"10:00-12:30",
"18:00-20:30"
],
[
"02:00-04:30",
"10:00-12:30",
"18:00-22:30"
],
[
"02:00-04:30",
"10:00-14:30",
"18:00-22:30"
],
[
"02:00-06:30",
"10:00-14:30",
"18:00-22:30"
],
[
"02:00-06:30",
"10:00-14:30",
"18:00-22:30"
]
]
},
{
"date": "2023-01-17",
"name": "Tuesday",
"stages": [
[],
[
"16:00-18:30"
],
[
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-20:30"
],
[
"00:00-02:30",
"08:00-12:30",
"16:00-20:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-20:30"
]
]
},
{
"date": "2023-01-18",
"name": "Wednesday",
"stages": [
[
"00:00-02:30"
],
[
"00:00-02:30"
],
[
"00:00-02:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-04:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-04:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-04:30",
"08:00-10:30",
"16:00-20:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-20:30"
]
]
},
{
"date": "2023-01-19",
"name": "Thursday",
"stages": [
[
"08:00-10:30"
],
[
"00:00-02:30",
"08:00-10:30"
],
[
"00:00-02:30",
"08:00-10:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-12:30",
"16:00-18:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-18:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-18:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-20:30"
]
]
},
{
"date": "2023-01-20",
"name": "Friday",
"stages": [
[
"16:00-18:30"
],
[
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-18:30"
],
[
"00:00-02:30",
"08:00-10:30",
"16:00-20:30"
],
[
"00:00-02:30",
"08:00-12:30",
"16:00-20:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-20:30"
],
[
"00:00-04:30",
"08:00-12:30",
"16:00-20:30"
]
]
},
{
"date": "2023-01-21",
"name": "Saturday",
"stages": [
[
"22:00-00:30"
],
[
"14:00-16:30",
"22:00-00:30"
],
[
"06:00-08:30",
"14:00-16:30",
"22:00-00:30"
],
[
"06:00-08:30",
"14:00-16:30",
"22:00-00:30"
],
[
"06:00-08:30",
"14:00-16:30",
"22:00-00:30"
],
[
"06:00-08:30",
"14:00-18:30",
"22:00-00:30"
],
[
"06:00-10:30",
"14:00-18:30",
"22:00-00:30"
],
[
"06:00-10:30",
"14:00-18:30",
"22:00-00:30"
]
]
},
{
"date": "2023-01-22",
"name": "Sunday",
"stages": [
[],
[
"22:00-00:30"
],
[
"14:00-16:30",
"22:00-00:30"
],
[
"06:00-08:30",
"14:00-16:30",
"22:00-00:30"
],
[
"00:00-02:30",
"06:00-08:30",
"14:00-16:30",
"22:00-00:30"
],
[
"00:00-02:30",
"06:00-08:30",
"14:00-16:30",
"22:00-00:30"
],
[
"00:00-02:30",
"06:00-08:30",
"14:00-18:30",
"22:00-00:30"
],
[
"00:00-02:30",
"06:00-10:30",
"14:00-18:30",
"22:00-00:30"
]
]
}
],
"source": "https://example.com/test.schedule/current"
}
}
I have tried with various fields and tags configuration but I am getting nowhere. Here is some of the variations I have tried. I have added line comments on some of them to see if I get the response I would like, but alas.
data_format = "json_v2"
[[inputs.http.json_v2]]
measurement_name = "loadshedding"
[[inputs.http.json_v2.object]]
path = "schedule.days.0.stages"
# [[inputs.http.json_v2.tag]]
# path = "schedule.days.#.date"
# [[inputs.http.json_v2.field]]
# path = "schedule.days.0.stages.0.0"
# rename = "stage 1"
# [[inputs.http.json_v2.field]]
# path = "schedule.days.0.stages.1"
# rename = "stage 2"
If I had to take a wild guess at the LP I would like it would look something like this, all the way to stage 8:
Eskom,date=2023-01-16 stage_1="18:00-20:30" stage_2="10:00-12:30", "18:00-20:30" stage_3="02:00-04:30", "10:00-12:30","18:00-20:30"...
Apologies for the incorrect line protocol but its the best way I can explain it.
Thanks in advance.