sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.02k stars 176 forks source link

Manually executing check - no matching entities #5002

Open jhenderson-pro opened 1 year ago

jhenderson-pro commented 1 year ago

Expected Behavior

As a Sensu operator, I'd expect to be able to manually execute a check via the web UI or sensuctl if that check executes normally when scheduled.

Current Behavior

Currently, I have a check with an agent entity and proxy entity that does execute when scheduled but cannot manually execute via sensuctl or the web UI. This is the error:

2023-05-02 09:36:52 {"check":"scrape-snmp","component":"schedulerd","level":"warning","msg":"no matching entities, check will not be published","namespace":"default","time":"2023-05-02T15:36:52Z"}

Possible Solution

Steps to Reproduce (for bugs)

  1. Sensu Docker image
  2. Add check and proxy entity
  3. Let the check execute normally to show its functions as desired
  4. Manually execute check via sensuctl command or in the web UI
  5. See the error above in the logs

Context

Your Environment

jhenderson-pro commented 1 year ago

Resources:

resources.zip

c-kruse commented 1 year ago

Verified that an edge condition where requesting an adhoc execution of a check with proxy_requests configured results in incorrect behavior scheduling. This should be a relatively simple patch to fix.

diff --git a/backend/schedulerd/executor.go b/backend/schedulerd/executor.go
index a6b30570e..0675b4b9c 100644
--- a/backend/schedulerd/executor.go
+++ b/backend/schedulerd/executor.go
@@ -198,7 +198,8 @@ func (a *AdhocRequestExecutor) listenQueue(ctx context.Context) {
                        continue
                }

-               if err = a.processCheck(ctx, &check); err != nil {
+               checkCtx := corev2.SetContextFromResource(ctx, &check)
+               if err = a.processCheck(checkCtx, &check); err != nil {
                        select {
                        case a.listenQueueErr <- err:
                        case <-ctx.Done():

As pointed out in the sensu-engineering slack thread, this use case isn't very obviously useful, and isn't something users are very likely to run into.

ManishaKumari295 commented 8 months ago

Steps of execution of issue:

  1. Run sensuctl entity list and note the name of your agent entity (typically your hostname).
  2. Edit the provided check.yaml at line 34 to add the entity name. The line should be something like - entity:agentname.
  3. sensuctl create -f ./check.yaml
  4. sensuctl create -f ./proxy.yaml
  5. Wait a little bit and run sensuctl event info backend-entity prom-metrics and make sure an event is present.
  6. Once the event is present run sensuctl check execute prom-metrics It should print Issued.
  7. Verify the logs in backend logs , the "no matching entity " error must not be seen inspite the matched entity should be reflected.