Skip to content

Commit

Permalink
Merge branch '2-add-ssl-verify' into 'master'
Browse files Browse the repository at this point in the history
#2: Adds `GRAFANA_SSL_VERIFY`

See merge request ix.ai/grafana-email!16
  • Loading branch information
tlex committed Nov 24, 2022
2 parents 6219fce + 6234e99 commit d2e8ff9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
8 changes: 0 additions & 8 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ confidence=
disable=logging-fstring-interpolation,
# too-few-public-methods,
invalid-name,
no-self-use,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -251,13 +250,6 @@ max-line-length=120
# Maximum number of lines in a module.
max-module-lines=1000

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ You can see the panel url by selecting `Share` in a panel menu (click on its nam
| `PANEL_TIMEOUT` | - | NO | the timeout for Grafana to generate the panel |
| `GRAFANA_HEADER_HOST` | - | NO | useful if the hostname of the Grafana host/container is set to something than the FQDN in Grafana |
| `GRAFANA_URL_PARAMS` | - | NO | add additional URL params (example: `var-RequestHost=alex&var-Filters=OriginStatus\|!%3D\|404`) |
| `GRAFANA_SSL_VERIFY` | TRUE | NO | set to `FALSE` to ignore SSL certificate errors |
| `GRAFANA_TIMEOUT` | 60 | NO | the number of seconds to wait for the connection to Grafana |

## Examples
### Bash
Expand Down
11 changes: 10 additions & 1 deletion grafana-email/grafana-email.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def __init__(self):
self._smtp_user = os.environ.get('SMTP_USER')
self._smtp_password = os.environ.get('SMTP_PASSWORD')
self.grafana['ssl'] = os.environ.get('GRAFANA_SSL')
self.grafana['ssl_verify'] = os.environ.get('GRAFANA_SSL_VERIFY', 'TRUE').lower() in ['true', '1', 'yes', 'y']
self.grafana['timeout'] = int(os.environ.get('GRAFANA_TIMEOUT', 60))
self.grafana['host'] = os.environ.get('GRAFANA_HOST', 'grafana')
self.grafana['header_host'] = os.environ.get('GRAFANA_HEADER_HOST')
self.grafana['port'] = int(os.environ.get('GRAFANA_PORT', 3000))
Expand Down Expand Up @@ -89,7 +91,14 @@ def get_panels(self):
for panel in self.grafana['panel_ids'].split(','):
params['panelId'] = panel

response = requests.get(uri, params=params, headers=headers, stream=True)
response = requests.get(
uri,
params=params,
headers=headers,
stream=True,
verify=self.grafana['ssl_verify'],
timeout=self.grafana['timeout']
)
response.raw.decode_content = True
if response:
# self.panels.append({panel: base64.b64encode(imgObj).decode('UTF-8')})
Expand Down
2 changes: 1 addition & 1 deletion grafana-email/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.27.1
requests==2.28.1
pygelf==0.4.2
pillow>=6.2.1

0 comments on commit d2e8ff9

Please sign in to comment.