Skip to content

Commit

Permalink
Merge pull request #27 from mrzarquon/PIE-48
Browse files Browse the repository at this point in the history
Pie 48
  • Loading branch information
Helen authored Aug 12, 2019
2 parents bdc4ab5 + db6fcad commit 962cf81
Show file tree
Hide file tree
Showing 43 changed files with 128 additions and 134 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ This is an example query: `index=* sourcetype=puppet:summary`

If `puppet:detailed` sourcetype's are not showing up in search, that means that the Detailed Report Generator Alert is not configured or running properly. The app includes an alert that is disabled, but will trigger the alert as needed for any summary report that is submitted that isn't a normal, no change, puppet report. If this alert is enabled, and the setup screen has values in it, one can view the logs with the following Splunk search:

`index=_internal sourcetype=splunkd component=sendmodalert action="generate_detailed_report"`
`index=_internal sourcetype=splunkd component=sendmodalert (action="puppet_run_task_investigate" OR action="puppet_run_task" OR action="puppet_run_task_act" OR action="puppet_generate_detailed_report")`

There is also a view into the alert actions logs themselves (which are published to the HEC) under the Actions menu in the Splunk app that shows these searches as well.

If there are no error messages, then verify that the HEC token supplied works and can be used to submit an example report properly, runnging this command from a unix or command line will submit a dummy puppet:detailed event (such as a Splunk server):

Expand Down
11 changes: 6 additions & 5 deletions README/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ Release Notes
==============

2.0.0:
**Breaking Changes**:
- The alert action named `Generate detailed report` has been renamed `Generate a detailed Puppet report` to make it more specific. The internal name of the action has been renamed to `puppet_generate_detailed_report` from `generate_detailed_report` to prevent confusion with out alert actions and to ensure consistency with other. You will need to update existing searches using this action to use the new name, but no other changes to the searches is required.
- *alert actions will fail until Puppet Username is provided instead of PE auth token*
- *full URIs are now required instead of just hostnames* adds more flexibility the authorization methods (http support and custom ports) but you will need to redo your app configuration before alert actions resume functioning
- Searches defaulting to main and not using the index macros will stop updating if you move the corressponding puppet data to an index but don't change the search

New Features:
- Built in support for running Bolt Tasks in Puppet Enterprise from Splunk
- Metrics tab to show PE metric data if metrics are configured
- Actions Tab in dashboard added to show logs and status of any of this applications alert actions for debugging or auditing
- Support for Puppet Username/Password instead of auth token
- All searches support per sourcetype indexes

Breaking Changes:
- *alert actions will fail until Puppet Username is provided instead of PE auth token*
- *full URIs are now required instead of just hostnames* adds more flexibility the authorization methods (http support and custom ports) but you will need to redo your app configuration before alert actions resume functioning
- Searches defaulting to main and not using the index macros will stop updating if you move the corressponding puppet data to an index but don't change the search

Fixes:
- Alert actions work with custom parameters
- Before there was no way to see if your alerts were working easily, now they publish information to the puppet:action sourcetype
Expand Down
3 changes: 1 addition & 2 deletions README/alert_actions.conf.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

[generate_detailed_report]
param.transaction_uuid = <string> Transaction UUID.
[puppet_generate_detailed_report]

[puppet_run_task_investigate]
param.bolt_investigate_name = <list> Investigate. It's a required parameter. It's default value is lastlogin.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion TA-puppet-report-viewer.aob_meta

Large diffs are not rendered by default.

Binary file removed appserver/static/alert_generate_detailed_report.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 65 additions & 65 deletions appserver/static/js/build/globalConfig.json
Original file line number Diff line number Diff line change
@@ -1,185 +1,185 @@
{
"meta": {
"apiVersion": "3.0.0",
"name": "TA-puppet-report-viewer",
"displayName": "Puppet Report Viewer",
"restRoot": "TA_puppet_report_viewer",
"version": "2.0.0"
},
"pages": {
"configuration": {
"title": "Configuration",
"description": "Set up your add-on",
"tabs": [
{
"title": "Add-on Settings",
"name": "additional_parameters",
"entity": [
{
"label": "Puppet Enterprise Console",
"field": "puppet_enterprise_console",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Puppet Enterprise Console",
"defaultValue": "https://puppet.company.com",
"required": true,
"help": "URL to access the Puppet Enterprise console",
"type": "text",
"help": "URL to access the Puppet Enterprise console"
"required": true
},
{
"label": "Username",
"field": "puppet_read_user",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Username",
"defaultValue": "splunk",
"required": true,
"help": "Puppet Enterprise User with PuppetDB Access",
"type": "text",
"help": "Puppet Enterprise User with PuppetDB Access"
"required": true
},
{
"label": "Password",
"field": "puppet_read_user_pass",
"encrypted": true,
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of password is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Password",
"defaultValue": "",
"required": true,
"help": "",
"type": "text",
"help": ""
"required": true,
"encrypted": true
},
{
"label": "Splunk HEC URL",
"field": "splunk_hec_url",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Splunk HEC URL",
"defaultValue": "https://splunk.company.coml:8088/services/collector",
"required": true,
"defaultValue": "https://splunk.company.com:8088/services/collector",
"help": "URL to HEC services collector",
"type": "text",
"help": "URL to HEC services collector"
"required": true
},
{
"label": "HEC Token",
"field": "splunk_hec_token",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "HEC Token",
"defaultValue": "",
"required": true,
"help": "Token from HEC configured with puppet:summary or puppet:detailed sourcetype",
"type": "text",
"help": "Token from HEC configured with puppet:summary or puppet:detailed sourcetype"
"required": true
},
{
"label": "Bolt User",
"field": "bolt_user",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Bolt User",
"defaultValue": "",
"required": false,
"help": "Puppet Enterprise User with Bolt Task Access (if different from PuppetDB)",
"type": "text",
"help": "Puppet Enterprise User with Bolt Task Access (if different from PuppetDB)"
"required": false
},
{
"label": "Bolt Password",
"field": "bolt_user_pass",
"encrypted": true,
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of password is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Bolt Password",
"defaultValue": "",
"required": false,
"help": "",
"type": "text",
"help": ""
"required": false,
"encrypted": true
},
{
"label": "Orch. Services URL",
"field": "puppet_bolt_server",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Orch. Services URL",
"defaultValue": "",
"required": false,
"help": "Puppet Enterprise Orchestrator URL (derived from PE Console by default)",
"type": "text",
"help": "Puppet Enterprise Orchestrator URL (derived from PE Console by default)"
"required": false
},
{
"label": "Bolt Action Token",
"field": "puppet_action_hec_token",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "Bolt Action Token",
"defaultValue": "",
"required": false,
"help": "Provide token if using dedicated HEC for the puppet:action sourcetype",
"type": "text",
"help": "Provide token if using dedicated HEC for the puppet:action sourcetype"
"required": false
},
{
"label": "PuppetDB URL",
"field": "puppet_db_url",
"validators": [
{
"minLength": 0,
"maxLength": 8192,
"errorMsg": "Max length of text input is 8192",
"type": "string",
"maxLength": 8192
"type": "string"
}
],
"label": "PuppetDB URL",
"defaultValue": "",
"required": false,
"help": "URL to access PuppetDB (derived from PE Console by default)",
"type": "text",
"help": "URL to access PuppetDB (derived from PE Console by default)"
"required": false
}
]
],
"name": "additional_parameters",
"title": "Add-on Settings"
}
]
],
"title": "Configuration"
}
},
"meta": {
"version": "2.0.0",
"apiVersion": "3.0.0",
"name": "TA-puppet-report-viewer",
"restRoot": "TA_puppet_report_viewer",
"displayName": "Puppet Report Viewer"
}
}
2 changes: 1 addition & 1 deletion bin/TA_puppet_report_viewer_rh_settings.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'splunk_hec_url',
required=True,
encrypted=False,
default='https://splunk.company.coml:8088/services/collector',
default='https://splunk.company.com:8088/services/collector',
validator=validator.String(
max_len=8192,
min_len=0,
Expand Down
10 changes: 5 additions & 5 deletions bin/generate_detailed_report.py → bin/puppet_generate_detailed_report.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import sys

from alert_actions_base import ModularAlertBase
import modalert_generate_detailed_report_helper
import modalert_puppet_generate_detailed_report_helper

class AlertActionWorkergenerate_detailed_report(ModularAlertBase):
class AlertActionWorkerpuppet_generate_detailed_report(ModularAlertBase):

def __init__(self, ta_name, alert_name):
super(AlertActionWorkergenerate_detailed_report, self).__init__(ta_name, alert_name)
super(AlertActionWorkerpuppet_generate_detailed_report, self).__init__(ta_name, alert_name)

def validate_params(self):

Expand Down Expand Up @@ -42,7 +42,7 @@ def process_event(self, *args, **kwargs):
try:
if not self.validate_params():
return 3
status = modalert_generate_detailed_report_helper.process_event(self, *args, **kwargs)
status = modalert_puppet_generate_detailed_report_helper.process_event(self, *args, **kwargs)
except (AttributeError, TypeError) as ae:
self.log_error("Error: {}. Please double check spelling and also verify that a compatible version of Splunk_SA_CIM is installed.".format(ae.message))
return 4
Expand All @@ -57,5 +57,5 @@ def process_event(self, *args, **kwargs):
return status

if __name__ == "__main__":
exitcode = AlertActionWorkergenerate_detailed_report("TA-puppet-report-viewer", "generate_detailed_report").run(sys.argv)
exitcode = AlertActionWorkerpuppet_generate_detailed_report("TA-puppet-report-viewer", "puppet_generate_detailed_report").run(sys.argv)
sys.exit(exitcode)
Empty file modified bin/puppet_run_task.py
100644 → 100755
Empty file.
Empty file modified bin/puppet_run_task_act.py
100644 → 100755
Empty file.
Empty file modified bin/puppet_run_task_investigate.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/alert_actions_base.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/cim_actions.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/logging_helper.py
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# encoding = utf-8
import json
from puppet_report_generation import run_report_generation
Expand Down Expand Up @@ -34,11 +35,6 @@ def process_event(helper, *args, **kwargs):
puppet_db_url = helper.get_global_setting("puppet_db_url")
helper.log_info("puppet_db_url={}".format(puppet_db_url))
# The following example gets the alert action parameters and prints them to the log
transaction_uuid = helper.get_param("transaction_uuid")
helper.log_info("transaction_uuid={}".format(transaction_uuid))
# The following example adds two sample events ("hello", "world")
# and writes them to Splunk
# NOTE: Call helper.writeevents() only once after all events
Expand All @@ -57,7 +53,8 @@ def process_event(helper, *args, **kwargs):
helper.log_info("server_uri={}".format(helper.settings["server_uri"]))
[sample_code_macro:end]
"""
helper.log_info("Alert action Generate Detailed Report started.")

helper.log_info("Alert action puppet_generate_detailed_report started.")

# Lets generate that dict we need

Expand All @@ -84,4 +81,5 @@ def process_event(helper, *args, **kwargs):

helper.log_info("run_report_generation completed successfully.")

return 0
# TODO: Implement your alert action logic here
return 0
Empty file.
Empty file modified bin/ta_puppet_report_viewer/modalert_puppet_run_task_helper.py
100644 → 100755
Empty file.
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/__init__.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/__main__.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/bolt.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/hec.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/pdb.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/rbac.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/util.py
100644 → 100755
Empty file.
Empty file modified bin/ta_puppet_report_viewer/pie/vops.py
100644 → 100755
Empty file.
Loading

0 comments on commit 962cf81

Please sign in to comment.