St2-netbox-webhook data


(LuisN) #1

Is there a way to view the payload data in logs from an incoming webhook?

(Lindsay Hill) #2

You could just use a core.local action to dump everything to a file.

Or you could read the Netbox docs. That would probably be much simpler.

(LuisN) #3

Netbox doc for st2 ? i wish it had rule examples like other packs have

(LuisN) #4

So either there is no data in the payload or i have the criteria wrong

2019-03-08 13:20:58,641 140478644659216 INFO _internal [-] - - [08/Mar/2019 13:20:58] “POST /netbox/webhooks/ HTTP/1.1” 200 -

“description”: “test2”,
“tags”: [],
“type”: {
“ref”: “standard”,
“parameters”: {}
“enabled”: true,
“trigger”: {
“type”: “netbox.webhook.object_created”,
“ref”: “netbox.webhook.object_created”,
“description”: “Object created”,
“parameters”: {}
“metadata_file”: “”,
“context”: {
“user”: “stanley”
“criteria”: {
“”: {
“pattern”: “webhook.object_created”,
“type”: “equals”
“action”: {
“ref”: “chatops.post_message”,
“description”: “Post a message to stream for chatops”,
“parameters”: {
“message”: “worked! Netbox”,
“channel”: “#development
“uid”: “rule:netbox:test2”,
“pack”: “netbox”,
“ref”: “netbox.test2”,
“id”: “5c82b1b655fdfa039c996b88”,
“name”: “test2”

(Lindsay Hill) #5

How do you know that there’s no data in the payload? In the above rule you don’t do anything with the payload.

Just create a rule with no criteria, and dump the whole payload to file.

(LuisN) #6

I tried that, didnt work until i did trigger to get the entire output. Even if i try trigger.payload to file i get

  "traceback": "  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/rules/\", line 200, in _invoke_action\n    additional_contexts=additional_contexts)\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/rules/\", line 82, in get_resolved_parameters\n    additional_contexts=additional_contexts)\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/\", line 297, in render_live_params\n    context = _resolve_dependencies(G)\n  File \"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/\", line 215, in _resolve_dependencies\n    raise ParamException(msg)\n",
  "error": "Failed to render parameter \"cmd\": 'mongoengine.base.datastructures.BaseDict object' has no attribute 'payload'"

i looked at the output using trigger, and it does show payload

  "status": "processed",
  "occurrence_time": "2019-03-09T16:43:37.000000Z",
  "trigger": "netbox.webhook.object_updated",
  "id": "5c84338a55fdfa02b51ef958",
  "payload": {
    "timestamp": "2019-03-09 21:43:37.920206",
    "model": "device",

(LuisN) #7

Maybe the pack is a bit behind the updates? Really wondering why i cant call each object

(Lindsay Hill) #8

What is your rule? Just dump the entire payload. Take a look at what’s in it.

The sensor code is fairly trivial too, it’s only a few lines. You could look through that