-
Notifications
You must be signed in to change notification settings - Fork 493
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
Refactor Alert Service #1209
Refactor Alert Service #1209
Conversation
f6721cf
to
c324fcb
Compare
073d874
to
0375e6d
Compare
0d60091
to
f0efb9b
Compare
64cb0c3
to
0085fd9
Compare
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.
From what I can tell it seems good. Going to Read over it another time.
This may just be due to my own misunderstanding, but it seems like its not possible to create a topic without using it in a TICKscript. Is this correct?
httpd.HttpError(w, fmt.Sprint("invalid pattern: ", err.Error()), true, http.StatusBadRequest) | ||
return | ||
} | ||
minLevelStr := r.URL.Query().Get("min-level") |
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.
Not a really an issue since this isn't a hot code path, but URL.Query()
generates a new map each time its called.
services/alert/handlers.go
Outdated
h.next = n | ||
} | ||
func (h *stateChangesOnlyHandler) Close() {} | ||
// TODO implement state changes only as a match condition |
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.
What does this mean?
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.
Ah, yes so with the change to not have handler actions
anymore there is no way to do stateChangesOnly via a handler.
The proposed solution is to use match criteria on handlers. So something like this
id: my_handler
topic: system
kind: slack
options:
channel: '#alerts'
match: "changed" == TRUE AND "sometag" == 'bob'
Where the match
property is a lambda expression then when it evals to true then the handler handles the alert event. This way we get the same functionality back but in a more consistent manner.
I was thinking we should add the match
expression logic in another PR so that its can remain as an independent change. Or should we lump it in here so that we maintain feature parity from the get go? Thoughts?
No quite, Topics are created whenever they are referenced so there is no need to explicitly create them. So if they are referenced in a TICKscript they are created as well as if a handler references a topic it will be created. |
Ah I see. I spent some time confused about this. Here's the process I just went through. First I created a task with this tickscript
Then
I noticed the
From here I noticed
So I make a
and then I run
No errors, so moving on.
Hmm, then I run
Hmm, so I rerun
This time I notice
and I notice this time that you specify the topic id as the first positional argument to the command. Then everything was fine. This confusion was definitely due to me not reading, but the positional arguments vs flags split is different than what I'm used to with kapacitor. The two other
where positional arguments are used for naming things and flags are used to specify details. |
@desa Thanks for the walk through. Agreed lets change it to be more consistent. Would this be more clear?
The difference here is that the ID is in the yaml file. Should we move the ID out of the yaml file so that the ID is specified on the command line? |
@nathanielc With
defines a single task and reissuing that command with different flags redefines the task
and
define two different handlers. I keep mulling over different ways of going about it and I cant think of one I like. Syntacticly, I like
the most. Just because its very similar to how the other |
This is why I made it an positional argument. In other words the ID for a handler is topicID and handlerID together. |
maybe changing the name of the command?
|
I like that, its a bit verbose but that is what tab completion is for :) I did a similar thing in the Go client. |
or what about moving the topic into the handler config
and just having
|
I like
And It creates a more consistent treatment of handlers, such that they are always referenced in the scope of a topic. |
👍 |
Final thought. Maybe this is what you were already thinking, but what about something like
with
|
@desa I have pushed an updated CLI, could you look it over and see how UX is? |
For some reason github wont let me directly comment on where some of the issues are. kapacitor/cmd/kapacitor/main.go Line 1833 in ec9dc79
Should say topic-handlers kapacitor/cmd/kapacitor/main.go Line 1849 in ec9dc79
kapacitor/cmd/kapacitor/main.go Line 1868 in ec9dc79
Should say topic-handlers kapacitor/cmd/kapacitor/main.go Line 2002 in ec9dc79
Should say topic-handlers Just a couple copy issues. Personally, I think I'd prefer having the handler configuration be specified as a flag, but I don't particularly mind it the way that it currently is. |
6e0ce1e
to
0553eab
Compare
I started that way and then reversed it because Go is picky about where flags need to be, so it would always have to be the last or first argument which basically turned it into a positional argument. And it is not an optional argument which a flag implies. I'll fix the other issues. |
0553eab
to
64bd6b2
Compare
…m/google/uuid subrepo: subdir: "vendor/github.com/google/uuid" merged: "6a5e28554" upstream: origin: "https://github.com/google/uuid.git" branch: "master" commit: "6a5e28554" git-subrepo: version: "0.3.0" origin: "???" commit: "???"
64bd6b2
to
adb37b7
Compare
8b0148d
to
9b4b259
Compare
@desa The migration path is ready for testing. You should be able to
|
@nathanielc Just did a manual test and verified that this process works. |
9b4b259
to
1521a8c
Compare
This is a refactor of the Alert Service there are a handful of changes:
TODO