-
Notifications
You must be signed in to change notification settings - Fork 49
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 JSON field support #55
Conversation
toddtreece
commented
Nov 18, 2022
- buffer in chunks and push chunks on the query interval
- add JSON field type support
- update form layouts
go.mod
Outdated
go 1.16 | ||
go 1.19 | ||
|
||
replace github.com/grafana/grafana-plugin-sdk-go => /home/todd/grafana-plugin-sdk-go |
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.
^^^. remove before commit
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.
removed in 88e5496
src/plugin.json
Outdated
@@ -37,7 +37,7 @@ | |||
"updated": "%TODAY%" | |||
}, | |||
"dependencies": { | |||
"grafanaDependency": ">=8.0.0", | |||
"grafanaDependency": ">=9.2.0", |
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.
any reason to bump all the way to 9.2? with 8.5, i think all the relevant APIs are the same
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.
SecretInput
is missing pre 9.1.x, so i set the dependency to 9.1.0 in 5105e8d. i was thinking that the first official release should target a recent 9.x version since we don't have a lot of bandwidth to support 8.x issues. thoughts?
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.
sounds reasonable -- especially for cloud
return &MQTTDatasource{ | ||
Client: client, | ||
channelPrefix: fmt.Sprintf("ds/%s/", uid), | ||
channelPrefix: path.Join("ds", uid), |
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.
does this always use /
? on windows does it use \
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.
path/filepath
is OS aware, but path.Join
always uses /
This looks good -- What do you think about copying: to this plugin and using it directly? Things got stalled with this plugin since I had hoped to use that in grafana server, but I don't see us getting that super production ready anytime soon |
fieldMap map[string]int | ||
} | ||
|
||
func (df *framer) next() error { |
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.
@ryantxu i attempted to modify the framer you linked to fit this use case. is this kind of what you were thinking?
@@ -0,0 +1,22 @@ | |||
# default configuration created by the `mage watch` command. |
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.
mage watch
was added in grafana/grafana-plugin-sdk-go#563
Hey. First of all thanks for implementing this.
case jsoniter.StringValue:
v := df.iterator.ReadString()
time, err := time.Parse(time.RFC3339, v)
if err != nil {
df.addValue(data.FieldTypeNullableString, &v)
} else {
df.addValue(data.FieldTypeNullableTime, &time)
} I don't know what exactly triggers the two errors above, but with main i don't have these problems as it seems. Maybe i do something wrong ? My test value: {
"timestamp": "2022-11-08T09:05:50.989644528Z",
"available": true,
"ownership": "",
"attached": true,
"state": "attach",
"P": -65440,
"Q": -1930,
"PSet": -65229.046875,
"QSet": -1985.50830078125,
"PLim": [
100000,
100000,
100000,
100000
]
} |
are there any other errors in your logs? it kind of seems like the plugin might be panicking and restarting
@NiklasCi thanks for testing! i'll follow up with a fix and test case for the field length issue.
this one could be nice to support in a future version if others request it, but for now i think it's covered by the convert field type transformation: |
Ok tested back. Only the field lenght issue is reproducible. So the first issue could be on my end.
Ah didn't know about the transformer. So my suggestion is not needed. |
@NiklasCi great, thanks for checking! |
3927d27
to
af9758a
Compare
@NiklasCi i think i have resolved the issues with field length. let me know if that works for you |
Works like a charm now. Even with big json files and arrays containing objects. |