-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lang parameter to OpenWeathermap input plugin #6504
Conversation
New fields: condition_description, condition_icon New tags: condition_id, condition_main
@@ -42,6 +47,8 @@ https://openweathermap.org/city/2643743 | |||
- tags: | |||
- city_id | |||
- forecast | |||
- condition_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swap condition_id
with condition_description
, making it a tag, and this a field. Also, is the _description
more valuable than the _main
? It seems like they are essentially duplicate data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong but I think it makes more sense to have ID as a tag and description as a field. Description is the same information as ID, but human readable and localized. I would rather select ID=802 than description="scattered clouds: 25-50%" or possibly a localization like "Mäßig bewölkt". Using ID to select means you don't have to know which language was enabled in the telegraf conf when the data was collected.
Description/ID is more valuable than main. You could map ID to main's value and leave out main completely. I included it for the same reasons as icon- It's part of OWM's API and someone familiar with it would think it's missing if we don't include it.
I made main a tag because it's a single word and it isn't localized. It might make sense to make it a field instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's part of OWM's API and someone familiar with it would think it's missing if we don't include it
It's quite common for telegraf to not create a metric from everything provided by an api. Some things just don't make sense as time series data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the human readable vs id: telegraf has standardized enum "codes" to be stored as fields and the string representations to be stored as tags. One example is the kube_inventory
plugin (state
and state_code
):
telegraf/plugins/inputs/kube_inventory/pod.go
Lines 55 to 63 in 817c9a6
"state_code": stateCode, | |
"terminated_reason": cs.State.Terminated.GetReason(), | |
} | |
tags := map[string]string{ | |
"container_name": *c.Name, | |
"namespace": *p.Metadata.Namespace, | |
"node_name": *p.Spec.NodeName, | |
"pod_name": *p.Metadata.Name, | |
"state": state, |
I would rather select ID=802
Very much agree. I'm not sure where/why you would do the other option. Both are still possible in either configuration from what I understand, but in influx, you can only group by
tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The influxdb schema design docs have some advice on choosing tags vs fields (https://docs.influxdata.com/influxdb/v1.7/concepts/schema_and_data_layout/). It says to make it a tag if it's commonly queried or used in a group by. Only tags are indexed, so querying on fields is slow.
After reading those docs I think I'd like to leave id and main as tags and description as a field. I imagine querying on and grouping by conditions will be common, so main and id should be tags. If you want the general condition like snowy days, use main="snow". If you want a specific condition like all days with freezing rain, use id="511". I think description isn't going to be commonly queried because it's localized and too long, so it should be a field.
I think the difference between this and kube_inventory is that kube_inventory's state is short (one word), only has three values, and isn't localized. That makes state easier to use than state_code, so it fits the tags criteria better.
I'd be fine leaving out icon but I don't think it's hurting anything. It doesn't give you much over id and main for grouping or querying, so if it stays it should be a field. It's only really useful if you build custom ui and need a weather conditions icon. I'm leaning towards leaving it in and letting people filter it out if they don't want it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the tag/field split is about right, I could imagine all the items being tags too since they all have a finite set of values, but I wouldn't go further in the field direction.
I checked on OWM's default unit and actually it isn't metric. To avoid changing behavior for telegraf people upgrading, I added back the telegraf metric default. There's still a check for expected units so you won't accidentally get metric if you misspelled standard or imperial like you did before. |
closes #6042
New fields: condition_description, condition_icon
New tags: condition_id, condition_main
Required for all PRs: