-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Heartbeat] Fix run from location in states loader #35336
Conversation
The states loader currently does not correctly read the location from the `heartbeat.run_from.id` config option. It's currently only applied to the `observer.*` fields. This patch fixes that.
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
Pinging @elastic/uptime (Team:Uptime) |
return func(sf stdfields.StdMonitorFields) (*State, error) { | ||
var runFromID string | ||
if sf.RunFrom != nil { |
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.
Shouldnt we default to using beatLocation
otherwise, passed as 3rd param in func?
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 purpose of this is that we want the fleet integration to set the location correctly, however the fleet integration can only set monitor fields, not root fields. Hence the precedence
@@ -131,6 +131,11 @@ func New(b *beat.Beat, rawConfig *conf.C) (beat.Beater, error) { | |||
}), | |||
trace: trace, | |||
} | |||
runFromID := "<unknown location>" |
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.
nit: we have default
value as runFrom Id in state and unknown
here, can we follow a common value.
@@ -54,9 +59,9 @@ func MakeESLoader(esc *eslegclient.Connection, indexPattern string, beatLocation | |||
}, | |||
} | |||
|
|||
if sf.RunFrom != nil { | |||
if runFromID != "" { |
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.
Found a bug with this approach, As we are passing the state query only when runFrom is specified. It leads to a bug when then runFrom is set and removed later.
- Set
heartbeat.runfrom
to atest-loc
, state will created on index<monitorstate:id=test-loc-<blah>>
- Remove the value of
run_from
, now instead of checking thedefault
location or unknown if we change the naming. We will be look at the wrong index for the monitor.
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.
LGTM
* [Heartbeat] Fix run from location in states loader The states loader currently does not correctly read the location from the `heartbeat.run_from.id` config option. It's currently only applied to the `observer.*` fields. This patch fixes that. * Fix errcheck * Add tests * Fixes * Add changelog * More nil checks --------- Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com> (cherry picked from commit 3550280)
* [Heartbeat] Fix run from location in states loader The states loader currently does not correctly read the location from the `heartbeat.run_from.id` config option. It's currently only applied to the `observer.*` fields. This patch fixes that. * Fix errcheck * Add tests * Fixes * Add changelog * More nil checks --------- Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com> (cherry picked from commit 3550280) Co-authored-by: Andrew Cholakian <andrewvc@elastic.co>
* [Heartbeat] Fix run from location in states loader The states loader currently does not correctly read the location from the `heartbeat.run_from.id` config option. It's currently only applied to the `observer.*` fields. This patch fixes that. * Fix errcheck * Add tests * Fixes * Add changelog * More nil checks --------- Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com>
The states loader currently does not correctly read the location from the
heartbeat.run_from.id
config option. It's currently only applied to theobserver.*
fields. This patch fixes that. It also makes the logs more clear.Note that we now log on each initial state for a monitor. This means one more log line, but only on the first exec of that monitor.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
Enable a monitor, either lightweight or browser, and set in your hearbeat config:
Then run with
Look for the output:
for your monitor, if it does not have previous state in ES
And if it does have previous state (which it should on the next run):
Note that the state ID should look like:
minneapolis-187e85ec8e9-0
where the first string is therun_from.id
value.