Skip to content
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

feat: implement extra info (tag, field) #46

Closed
wants to merge 2 commits into from

Conversation

c3y1huang
Copy link
Collaborator

@c3y1huang c3y1huang commented May 10, 2023

@c3y1huang c3y1huang marked this pull request as ready for review May 10, 2023 05:13
@c3y1huang c3y1huang changed the title feat(extra-info): create continuous queries feat: create continuous queries May 10, 2023
@c3y1huang c3y1huang self-assigned this May 10, 2023
Copy link
Member

@innobead innobead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, LGTM.

Let Phan do the final review. Also, I am curious why kubernetes_version is able to collect now. I did not see the code here before this implementation. Or we use a different branch for Longhorn?

@PhanLe1010 Please do the review before merging.

Copy link
Collaborator

@PhanLe1010 PhanLe1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are creating continuous queries automatically for app developers. Suggesting to modify the documentation

upgrade-responder/README.md

Lines 128 to 153 in b5b3035

### Add kubernetesVersion extra field
For example, if you want to keep track of the number of your application instances by each Kubernetes version, you may want to include Kubernetes version into `extraInfo` in the request's body sent to Upgrade Responder server.
The request's body may look like this:
```json
{
"appVersion": "v0.8.1",
"extraInfo": {
"kubernetesVersion": "v1.19.1"
}
}
```
In order to display statical information about Kubernetes version on Grafana dashboard, you need to do:
1. Create a continuous query in the InfluxDB to periodically group data by Kubernetes version
```
CREATE CONTINUOUS QUERY "cq_by_kubernetes_version_down_sampling" ON "<application-name>_upgrade_responder" BEGIN SELECT count("value") as total INTO "by_kubernetes_version_down_sampling" FROM "upgrade_request" GROUP BY time(1h),"kubernetes_version" END
```
where:
* `cq_by_kubernetes_version_down_sampling` is the name of the new continuous query (chosen by you)
* `<application-name>_upgrade_responder` is the name of the database prefixed by your application's name
* `by_kubernetes_version_down_sampling` is the name of the new measurement (chosen by you)
* `upgrade_request` is the original measurement where Upgrade Responder server records data to
* `1h` is the query period. Make sure that this value is the same as `--query-period`
* `kubernetes_version` is the tag to grouping data. This is derived from the camelcase form of `kubernetesVersion` to its snakecase form.
1. Create a Grafana panel that pull data from the new measurement `by_kubernetes_version_down_sampling` similar to this:
![Alt text](./assets/images/grafana_query_by_kubernetes_version.png?raw=true)

Also, we need to update the Grafanar dashboard afterward.

upgraderesponder/service.go Outdated Show resolved Hide resolved
upgraderesponder/service.go Outdated Show resolved Hide resolved
@PhanLe1010
Copy link
Collaborator

After this PR, the upgrade-responder server will create a continuous query for each user-submitted tag value. This can potentially be abused by a malicious user sending a request with a lot of tags and crashing our database. I am thinking to verify the user-submitted data based on a config file similar to https://github.com/longhorn/upgrade-responder/blob/b5b303538e1e2920a97f0afb7e6fb1ce5e2ea143/config/response.json#L1-L26

This will be tracked at the ticket https://github.com/longhorn/upgrade-responder/issues/47

@innobead
Copy link
Member

That's possible, especially right now this service is quite public and anonymous. It's better to use white list to achieve that.

ref: 5235

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
@c3y1huang c3y1huang force-pushed the feat-extra-info branch 3 times, most recently from 092cc6b to f327113 Compare June 13, 2023 08:53
@c3y1huang c3y1huang force-pushed the feat-extra-info branch 2 times, most recently from 28ca1e9 to 3b0c787 Compare June 14, 2023 10:51
@c3y1huang c3y1huang changed the title feat: create continuous queries feat: implement extra info (tag, field) Jun 14, 2023
@c3y1huang c3y1huang force-pushed the feat-extra-info branch 3 times, most recently from b80e29a to 64c48fa Compare June 16, 2023 06:51
@c3y1huang c3y1huang marked this pull request as draft June 16, 2023 08:25
@c3y1huang c3y1huang force-pushed the feat-extra-info branch 2 times, most recently from d79c0cf to ed6684e Compare June 16, 2023 10:26
@c3y1huang c3y1huang marked this pull request as ready for review June 16, 2023 10:31
ref: 5235

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
@c3y1huang c3y1huang force-pushed the feat-extra-info branch 2 times, most recently from 96a5396 to 6145b60 Compare June 19, 2023 06:17
Copy link
Collaborator

@PhanLe1010 PhanLe1010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created the PR #48 which contains the logic of this PR as well as the logic for user-data verification. Is it ok to use that PR in favor of this PR @c3y1huang @innobead? Thank you very much

return
}

s.dbCache.AddPoint(pt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iwith this AddPoint() and the one below it, we are adding 2 points for 1 request which will make the number of node count double because the number of nodes == number of requests

return nil
}

func (s *Server) addContinuousQuerieStringsFromTags(databaseName string, queryStrings map[string]string) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking that the main focus for the extra tag info and extra field info is to understand the distribution of different values/settings currently. Therefore, I think we don't need to create continuous queries because we can use the data in the last hour to visualize all kind of distribution. What do you think?

@innobead
Copy link
Member

I have created the PR #48 which contains the logic of this PR as well as the logic for user-data verification. Is it ok to use that PR in favor of this PR @c3y1huang @innobead? Thank you very much

I am OK with that. @c3y1huang WDYT?

@c3y1huang
Copy link
Collaborator Author

I have created the PR #48 which contains the logic of this PR as well as the logic for user-data verification. Is it ok to use that PR in favor of this PR @c3y1huang @innobead? Thank you very much

I am fine with this.

@c3y1huang c3y1huang closed this Jun 26, 2023
@c3y1huang c3y1huang deleted the feat-extra-info branch June 26, 2023 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants