Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

/tags/delByQuery: support for archiving metrics, not just deletion #1978

Merged
merged 4 commits into from
May 18, 2021

Conversation

shanson7
Copy link
Collaborator

Resolves #1977

@Dieterbe
Copy link
Contributor

can you update the ## Deleting tagged metrics (Preferred Method) section in docs/http-api.md accordingly?

deleted, err := s.MetricIndex.DeleteTagged(request.OrgId, query)
return len(deleted), err
}
matched, _ := s.MetricIndex.FindTerms(request.OrgId, []string{}, query)
return int(matched), nil
return 0, fmt.Errorf("Unknown delete method '%s'", request.Method)
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty sure the model validation already takes care of this case. but anyway, doesn't hurt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Model validation takes care of this when this code and the validation code agree. This is just defensive handling in case these code sections accidentally get out of sync.

@@ -162,14 +162,16 @@ type IndexTagDelByQuery struct {
OrgId uint32 `json:"orgId" binding:"Required"`
Expr []string `json:"expressions" binding:"Required"`
OlderThan int64 `json:"olderThan" form:"olderThan"`
Execute bool `json:execute binding:"Default(false)"`
Execute bool `json:"execute" binding:"Default(false)"`
Copy link
Contributor

Choose a reason for hiding this comment

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

oopsie

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps we need another static validator to catch typos like this

Copy link
Contributor

@Dieterbe Dieterbe left a comment

Choose a reason for hiding this comment

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

looks good!
just the docs tweak and this is good to merge

@Dieterbe Dieterbe changed the title Archive by query /tags/delByQuery: support for archiving metrics, not just deletion May 18, 2021
@Dieterbe Dieterbe merged commit 1b533db into grafana:master May 18, 2021
@shanson7 shanson7 deleted the archiveByQuery branch May 18, 2021 12:59
@shanson7
Copy link
Collaborator Author

Thanks @Dieterbe!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support "archive" in tags/delByQuery
2 participants