# Help: Does anyone have for me a working example of proxies and a sensu.CheckDependencies

**URL:** <https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621>\
**Category:** Sensu Go\
**Created:** [June 29, 2021, 7:55am UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621 "2021-06-29T07:55:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![daswars](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/daswars/32/510_2.png) [@daswars](https://discourse.sensu.io/u/daswars)\
**Post date:** [June 29, 2021, 7:55am UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/1 "2021-06-29T07:55:09Z")

</div>

Does anyone have for me a working example of proxies and a sensu.CheckDependencies

I have many proxys with snmp checks and a opsgenie handler.  
A proxy has 8 checks with different snmp checks.  
Plus one ping check.  
When I currently have a failure, I get 9 messages, only from one proxy.  
I want to reduce this mass of messages with CheckDependencies.  
Can someone here post me an example how this works in detail?

I use sensu ee in the latest version (6.4)

Thanks

```auto
type: CheckConfig
api_version: core/v2
metadata:
  annotations:
    fatigue_check/occurrences: "3"
  labels:
    sensu.io/workflow: sensu-flow
  name: check-ping-proxy
spec:
  command: check_fping {{.labels.ping_hostname}} -n 3 -v
  handlers:
    - opsgenie
  high_flap_threshold: 0
  interval: 60
  low_flap_threshold: 0
  output_metric_format: nagios_perfdata
  output_metric_handlers:
    - influxdb
  proxy_entity_name: check-ping-proxy
  proxy_requests:
    entity_attributes:
      - entity.entity_class == 'proxy'
      - entity.labels.ping == 'true'
    splay: false
    splay_coverage: 90
  publish: true
  round_robin: true
  runtime_assets:
    - sensu-plugins-monitoring-plugins
  stdin: false
  subscriptions:
    - proxy
  timeout: 30
  ttl: 0

```

```auto
type: EventFilter
api_version: core/v2
metadata:
  labels:
    sensu.io/workflow: sensu-flow
  name: check-ping-proxy
spec:
  action: allow
  expressions:
    - sensu.CheckDependencies("check-ping-proxy")

```

```auto
---
type: Handler
api_version: core/v2
metadata:
  labels:
    sensu.io/workflow: sensu-flow
  name: opsgenie
spec:
  type: pipe
  command: 'sensu-opsgenie-handler --withAnnotations --withLabels --priority "{{.Entity.Annotations.opsgenie_priority}}" --sensuDashboard "https://sensu.local/c/~/n" --fullDetails --addHooksToDetails'
  env_vars:
  - OPSGENIE_TEAM=itops
  - OPSGENIE_REGION=us
  - OPSGENIE_AUTHTOKEN=zzzzzz
  timeout: 60
  runtime_assets:
  - sensu-opsgenie-handler
  filters:
    - is_incident
    - not_silenced
    - fatigue_check
    - check-ping-proxy

```

```auto
---
type: CheckConfig
api_version: core/v2
metadata:
  annotations:
    fatigue_check/occurrences: "3"
  labels:
    sensu.io/workflow: sensu-flow
  name: check-AdminLoginAttempts
spec:
  command: 'check_snmp -P {{.labels.snmp_protocol | default "3"}} -timeout={{.labels.snmp_timeout | default "90"}} -retries={{.labels.snmp_retries | default "5"}} -hostname={{.labels.hostname}} -secname={{.labels.snmp_secname}} -authpasswd={{.labels.snmp_authpasswd}} -privpasswd={{.labels.snmp_privpasswd}} -seclevel={{.labels.snmp_seclevel | default "public"}} -authproto={{.labels.snmp_authproto | default "SHA"}} -privproto={{.labels.snmp_privproto | default "AES"}} -oid=.1.3.6.1.4.1.23629.1.5.1.2.1.16.{{.labels.snmp_serialnumber}} -label=AdminLoginAttempts -warning=3: -critical=1:'
  handlers: []
  high_flap_threshold: 60
  interval: 300
  low_flap_threshold: 20
  output_metric_format: nagios_perfdata
  output_metric_handlers:
    - influxdb
  proxy_entity_name: check-AdminLoginAttempts
  proxy_requests:
    entity_attributes:
      - entity.entity_class == 'proxy'
      - entity.labels.proxy_type == 'check-snmp-loginattempts'
    splay: true
    splay_coverage: 90
  publish: true
  round_robin: true
  runtime_assets:
    - sensu-plugins-monitoring-plugins
  stdin: false
  subscriptions:
    - proxy
  timeout: 160
  ttl: 0

```

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [June 29, 2021, 4:51pm UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/2 "2021-06-29T16:51:18Z")

</div>

> [@daswars](#):
>
> `CheckDependencies`

Hey!

Based on the configuration you’ve provided I’m not sure sensu.CheckDependencies is what you want… or you need to adapt your config so CheckDependencies works.

I’m suspicious that your CheckConfig for your proxy check is collapsing all the generated events into a single event. I think, the proxy\_entity\_name attribute is causing all runs of the check by all proxy entities to rewrite the entity name to be “check-ping-proxy” Can you double check that for me?

sensu.CheckDependancies only makes sense to me if you either have  
a) events from different entities  
b) events from different checks from the same entity

Right now based on your configuration, I don’t think have either case.

---

<div class="post-metadata">

**Author:** ![daswars](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/daswars/32/510_2.png) [@daswars](https://discourse.sensu.io/u/daswars)\
**Post date:** [July 2, 2021, 8:57am UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/3 "2021-07-02T08:57:02Z")

</div>

> [@jspaleta](#):
>
> CheckDependancies

OK,  
I’ll try to explain in more detail how my setup looks like.

I monitor several systems via SNMP. Each of these systems is also tested with a ping check.  
For the SNMP check I use:  
check\_snmp  
Each of the systems has not only one check but 3-12.  
Here are of course 3-12 different checks in sensu meant. So each has a different name and proxy\_entity\_name.  
E.g:

- OperationErrors
- PartitionStorageAllocatedBytes
- PartitionsFree  
Now I want to prevent 4-13 alerts in case of a failure, but only 1-2 alerts maximum per proxy/agent.

I didn’t quite understand your statement with the parameter proxy\_entity\_name. I have always used this until now without I think understanding exactly why and how this is used.

That’s why I thought that the method CheckDependancies is the right one.  
But currently I can’t get this to work.  
And I haven’t found a real-live-example either here in the forum or on Github yet.

My desired result would be for starters,  
if a ping fails, no alert should communicate a message via handler(opsgenie).

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [July 2, 2021, 6:22pm UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/4 "2021-07-02T18:22:12Z")

</div>

Hey,

First… in your filter named ‘check-ping-proxy’ you have

```auto
sensu.CheckDependencies("check-ping-proxy")

```

The intepretation of this line is that CheckDependencies will be checking to see if any Sensu events with the check name “check-ping-proxy” are non-zero status. When called by a handler attached to “check-ping-proxy”, as in your configuration, this only does anything useful if there are multiple events with a check name of “check-ping-proxy”

Let’s check if that’s true:

```auto
sensuctl event list --field-selector 'event.check.name == "check-ping-proxy"'

```

If there is only one event returned using that field-selector filter then CehckDependencies either not what you want, or you are asking CheckDependencies to look at the wrong check name, or you have a misconfigured proxy check configuration. So let’s start there.  
Does that filtered event list return more than on event, from different entities? Or does it return just one event with entity name `check-ping-proxy`

---

<div class="post-metadata">

**Author:** ![daswars](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/daswars/32/510_2.png) [@daswars](https://discourse.sensu.io/u/daswars)\
**Post date:** [July 5, 2021, 6:57am UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/5 "2021-07-05T06:57:11Z")

</div>

I get several entities back here, of course. Since I use this also in several Entitys-proxys.  
But what is the right way to reduce a CheckDependencies in only one entity?  
So I am looking for a Keepalive alternative for Entitys-proxys.

---

<div class="post-metadata">

**Author:** ![daswars](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/daswars/32/510_2.png) [@daswars](https://discourse.sensu.io/u/daswars)\
**Post date:** [July 28, 2021, 6:54am UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/6 "2021-07-28T06:54:07Z")

</div>

> [@jspaleta](#):
>
> check-ping-proxy

Here is a recent example for a better understanding. I have 3 proxys Entitys

appliance1 (only (icmp/snmp allows)  
- check-ping-proxy → DOWN  
- snmp-disksize → DOWN  
- snmp-temperature → DOWN  
- snmp-fanspeed → DOWN  
appliance2 (only snmp allow)  
- check-ping-proxy → UP  
- snmp-disksize → UP  
- snmp-temperature → UP  
- snmp-fanspeed → DOWN  
appliance3 (only snmp allow)  
- check-ping-proxy → UP  
- snmp-disksize → UP  
- snmp-temperature → UP  
- snmp-fanspeed → UP

The result should be,  
that I get only two alerts in Opsgenie.  
appliance1 → check-ping-proxy  
appliance2 → snmp-fanspeed

Currently I get 4 alerts.  
Four from appliance1. That’s three too many for me.

In other words I need a keepalive for proxies

---

<div class="post-metadata">

**Author:** ![daswars](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/daswars/32/510_2.png) [@daswars](https://discourse.sensu.io/u/daswars)\
**Post date:** [August 13, 2021, 9:08am UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/7 "2021-08-13T09:08:38Z")

</div>

I have now created a separate handler for filter. With this it works.

check-ping-proxy.yaml

* * *

type: EventFilter  
api\_version: core/v2  
metadata:  
labels:  
[Sensu | Page not found](http://sensu.io/workflow:) sensu-flow  
name: filter-ping-proxy  
spec:  
action: allow  
expressions:  
- sensu.CheckDependencies(“check-ping-proxy”)

However, I don’t find the solution elegant. Since I now need a filter for each proxy check so a handler.

Unfortunately my custom filter does not work yet. can someone tell me why.

* * *

type: EventFilter  
api\_version: core/v2  
metadata:  
labels:  
[Sensu | Page not found](http://sensu.io/workflow:) sensu-flow  
name: check-ping-proxy  
spec:  
action: deny  
expressions:  
- ‘(function () { var pingEvent = sensu.EventStatus(“check-ping-proxy”); if (pingEvent != 0) { return true; } else{ return false; } })()’

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [June 9, 2022, 10:04pm UTC](https://discourse.sensu.io/t/help-does-anyone-have-for-me-a-working-example-of-proxies-and-a-sensu-checkdependencies/2621/8 "2022-06-09T22:04:34Z")

</div>

> [@daswars](#):
>
> `sensu.CheckDependencies`

So I think the BSM feature is actually what you probably need to use, it lets you build more expressive polling of Sensu events and map/reduce them into alerts into “service” level events that you can then alert on.
