Skip to content
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

Creating a new Rule #132

Closed
KrunchMuffin opened this issue Dec 31, 2015 · 5 comments
Closed

Creating a new Rule #132

KrunchMuffin opened this issue Dec 31, 2015 · 5 comments

Comments

@KrunchMuffin
Copy link
Contributor

I am trying to create a new rule to post to Slack webhook. How can i get the severity and the serverkey?

@oarevalo
Copy link
Owner

Here is a Slack rule that you can use as a guide: https://github.com/oarevalo/BugLogHQ-utils/tree/master/extensions/rules

@KrunchMuffin
Copy link
Contributor Author

I have most of that, although I am using attachments. Is there no way to get the serverkey? I want to show the environment.

        var payload = {
            "username": "BugLog",
            "icon_emoji": ":buglog:",
            "attachments": [
                {
                    "fallback": "#q.severityCode# - #q.message#: #getBugEntryHREF(q.EntryID)#",
                    "title": "#intro#",
                    "text": "<#getBugEntryHREF(q.EntryID)#|#q.severityCode# - #q.message#>",
                    "fields": [
                        {
                            "title": "Application",
                            "value": "#q.ApplicationCode#",
                            "short": true
                        },
                        {
                            "title": "Environment",
                            "value": "#ListLast(q.ApplicationCode,'_')#",
                            "short": true
                        },
                        {
                            "title": "Template",
                            "value": "#q.templatePath#",
                            "short": false
                        }
                    ],
                    "color": "danger"
                }
            ]
        };

@oarevalo
Copy link
Owner

from within your rule try this, I think this will return what you want:

getListener().getConfig().getConfigKey()

alternatively, if you are using instances, you can also use:

getListener().getInstanceName()

@KrunchMuffin
Copy link
Contributor Author

sweet! works great! Thanks!

@oarevalo
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants