Purpose of the Integration
This integration is intended to query Device42 from Slack and grab items directly on the Slack channel.
To setup up the integration:
- In Slack, go to the App section and click the “+”.
- Search for Device42 ChatOps.
- Install it.
- In D42, create an external integration for Slack.
- For the URL, set it to your Slack workspace URL
https://.....slack.com - For the token, you will need to create a secret where the password is the value for the Bot User OAuth Access Token.
In Slack you run slash commands to use the integration (Communication with the Cloud Connector must work to use this command)
/d42
NOTE: All the commands must be run under "Device42 ChatOps" Slack channel.
After the slash command, you use one of the D42 commands. They are:
help - prints help information
list - run DOQL query where it returns fields you specify and could apply an optional limit
show - run DOQL query where it returns fields you specify and filters on a specific field and value
search - run DOQL query where it returns all fields filters on a specific field and value.
This is similar to the show command. The only difference is that you cannot specify which fields you want returned.
Output example for the /d42 help
list
These are the arguments you can use.
-o or --object - The view to use for the query. This is required. You can specify the entire view name (e.g. view_device_v1) or just the part of the view name excluding the “view_” and “_v1”. So for example, for view_device_v1, you would use device. Note that this only works for v1 views. If you wanted to use a v2 view, you would need to pass the entire view name (e.g. view_database_v2).
-f or --fields - The fields to return. This is optional and if not specified, it will return all fields.
-l or --limit - The number of rows to limit to in the results. This is optional and if not specified, it will return all rows.
/d42 list --object view_device_v1 --fields “device_pk, name” limit 3
show
These are the arguments you can use.
-o or --object - The view to use for the query. This is required. You can specify the entire view name (e.g. view_device_v1) or just the part of the view name excluding the “view_” and “_v1”. So for example, for view_device_v1, you would use device. Note that this only works for v1 views. If you wanted to use a v2 view, you would need to pass the entire view name (e.g. view_database_v2).
-f or --fields - The fields to return. This is optional and if not specified, it will return all fields.
-k or --key - The field to filter on. This is required.
-v or --value - The field value to filter on. This is required. If you are searching for a string, it should be enclosed in double quotes.
/d42 show --object device --fields “device_pk, name” --key device_pk --value 123
search
These are the arguments you can use.
-o or --object - The view to use for the query. This is required. You can specify the entire view name (e.g. view_device_v1) or just the part of the view name excluding the “view_” and “_v1”. So for example, for view_device_v1, you would use device. Note that this only works for v1 views. If you wanted to use a v2 view, you would need to pass the entire view name (e.g. view_database_v2).
-k or --key - The field to filter on. This is required.
-v or --value - The field value to filter on. This is required. If you are searching for a string, it should be enclosed in double quotes.
/d42 search --object device --key device_pk --value “27”
All the output can be downloads as files and used outside of Slack if needed, especially when the number of items retrieved is big.
Comments
0 comments
Please sign in to leave a comment.