You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

528 lines
22 KiB

10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
5 years ago
update Readme with pip install dependencies pip install will fail when you cannot compile some of the dependencies. one is gcc the other is the Python.h ``` Building wheels for collected packages: rcssmin, rjsmin Running setup.py bdist_wheel for rcssmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ipfho29k/rcssmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-u0q6mggl --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rcssmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rcssmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rcssmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rcssmin.c -o build/temp.linux-x86_64-3.6/rcssmin.o unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for rcssmin Running setup.py clean for rcssmin Running setup.py bdist_wheel for rjsmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ipfho29k/rjsmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-axnaq3w9 --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rjsmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rjsmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rjsmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rjsmin.c -o build/temp.linux-x86_64-3.6/rjsmin.o unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ``` ``` Running setup.py bdist_wheel for rjsmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cfntw7bo/rjsmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ytqxu9_b --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rjsmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rjsmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rjsmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rjsmin.c -o build/temp.linux-x86_64-3.6/rjsmin.o In file included from rjsmin.c:18:0: _setup/include/cext.h:34:10: fatal error: Python.h: No such file or directory #include "Python.h" ^~~~~~~~~~ compilation terminated. ```
6 years ago
update Readme with pip install dependencies pip install will fail when you cannot compile some of the dependencies. one is gcc the other is the Python.h ``` Building wheels for collected packages: rcssmin, rjsmin Running setup.py bdist_wheel for rcssmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ipfho29k/rcssmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-u0q6mggl --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rcssmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rcssmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rcssmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rcssmin.c -o build/temp.linux-x86_64-3.6/rcssmin.o unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for rcssmin Running setup.py clean for rcssmin Running setup.py bdist_wheel for rjsmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ipfho29k/rjsmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-axnaq3w9 --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rjsmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rjsmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rjsmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rjsmin.c -o build/temp.linux-x86_64-3.6/rjsmin.o unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ``` ``` Running setup.py bdist_wheel for rjsmin ... error Complete output from command /home/ubuntu/webapps/hc-venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-cfntw7bo/rjsmin/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ytqxu9_b --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying ./rjsmin.py -> build/lib.linux-x86_64-3.6 running build_ext building '_rjsmin' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DEXT_MODULE=_rjsmin -UEXT_PACKAGE -I_setup/include -I/usr/include/python3.6m -I/home/ubuntu/webapps/hc-venv/include/python3.6m -c rjsmin.c -o build/temp.linux-x86_64-3.6/rjsmin.o In file included from rjsmin.c:18:0: _setup/include/cext.h:34:10: fatal error: Python.h: No such file or directory #include "Python.h" ^~~~~~~~~~ compilation terminated. ```
6 years ago
10 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. # Healthchecks
  2. ![Build Status](https://github.com/healthchecks/healthchecks/workflows/Django%20CI/badge.svg)
  3. [![Coverage Status](https://coveralls.io/repos/healthchecks/healthchecks/badge.svg?branch=master&service=github)](https://coveralls.io/github/healthchecks/healthchecks?branch=master)
  4. ![Screenshot of Welcome page](/static/img/welcome.png?raw=true "Welcome Page")
  5. ![Screenshot of My Checks page](/static/img/my_checks.png?raw=true "My Checks Page")
  6. ![Screenshot of Period/Grace dialog](/static/img/period_grace.png?raw=true "Period/Grace Dialog")
  7. ![Screenshot of Cron dialog](/static/img/cron.png?raw=true "Cron Dialog")
  8. ![Screenshot of Integrations page](/static/img/channels.png?raw=true "Integrations Page")
  9. Healthchecks is a cron job monitoring service. It listens for HTTP requests
  10. and email messages ("pings") from your cron jobs and scheduled tasks ("checks").
  11. When a ping does not arrive on time, Healthchecks sends out alerts.
  12. Healthchecks comes with a web dashboard, API, 25+ integrations for
  13. delivering notifications, monthly email reports, WebAuthn 2FA support,
  14. team management features: projects, team members, read-only access.
  15. The building blocks are:
  16. * Python 3.6+
  17. * Django 3
  18. * PostgreSQL or MySQL
  19. Healthchecks is licensed under the BSD 3-clause license.
  20. Healthchecks is available as a hosted service
  21. at [https://healthchecks.io/](https://healthchecks.io/).
  22. ## Setting Up for Development
  23. To set up Healthchecks development environment:
  24. * Install dependencies (Debian/Ubuntu):
  25. $ sudo apt-get update
  26. $ sudo apt-get install -y gcc python3-dev python3-venv libpq-dev
  27. * Prepare directory for project code and virtualenv. Feel free to use a
  28. different location:
  29. $ mkdir -p ~/webapps
  30. $ cd ~/webapps
  31. * Prepare virtual environment
  32. (with virtualenv you get pip, we'll use it soon to install requirements):
  33. $ python3 -m venv hc-venv
  34. $ source hc-venv/bin/activate
  35. $ pip3 install wheel # make sure wheel is installed in the venv
  36. * Check out project code:
  37. $ git clone https://github.com/healthchecks/healthchecks.git
  38. * Install requirements (Django, ...) into virtualenv:
  39. $ pip install -r healthchecks/requirements.txt
  40. * Create database tables and a superuser account:
  41. $ cd ~/webapps/healthchecks
  42. $ ./manage.py migrate
  43. $ ./manage.py createsuperuser
  44. With the default configuration, Healthchecks stores data in a SQLite file
  45. `hc.sqlite` in the checkout directory (`~/webapps/healthchecks`).
  46. To use PostgreSQL or MySQL, see the section **Database Configuration** section
  47. below.
  48. * Run tests:
  49. $ ./manage.py test
  50. * Run development server:
  51. $ ./manage.py runserver
  52. The site should now be running at `http://localhost:8000`.
  53. To access Django administration site, log in as a superuser, then
  54. visit `http://localhost:8000/admin/`
  55. ## Configuration
  56. Healthchecks prepares its configuration in `hc/settings.py`. It reads configuration
  57. from two places:
  58. * environment variables (see the variable names in the table below)
  59. * it imports configuration for `hc/local_settings.py` file, if it exists
  60. You can use either mechanism, depending on what is more convenient. Using
  61. `hc/local_settings.py` allows more flexibility: you can set
  62. each and every [Django setting](https://docs.djangoproject.com/en/3.1/ref/settings/),
  63. you can run Python code to load configuration from an external source.
  64. Healthchecks reads configuration from the following environment variables:
  65. | Environment variable | Default value | Notes
  66. | -------------------- | ------------- | ----- |
  67. | [SECRET_KEY](https://docs.djangoproject.com/en/3.1/ref/settings/#secret-key) | `"---"`
  68. | [DEBUG](https://docs.djangoproject.com/en/3.1/ref/settings/#debug) | `True` | Set to `False` for production
  69. | [ALLOWED_HOSTS](https://docs.djangoproject.com/en/3.1/ref/settings/#allowed-hosts) | `*` | Separate multiple hosts with commas
  70. | [DEFAULT_FROM_EMAIL](https://docs.djangoproject.com/en/3.1/ref/settings/#default-from-email) | `"[email protected]"`
  71. | USE_PAYMENTS | `False`
  72. | REGISTRATION_OPEN | `True`
  73. | DB | `"sqlite"` | Set to `"postgres"` or `"mysql"`
  74. | [DB_HOST](https://docs.djangoproject.com/en/3.1/ref/settings/#host) | `""` *(empty string)*
  75. | [DB_PORT](https://docs.djangoproject.com/en/3.1/ref/settings/#port) | `""` *(empty string)*
  76. | [DB_NAME](https://docs.djangoproject.com/en/3.1/ref/settings/#name) | `"hc"` (PostgreSQL, MySQL) or `"/path/to/project/hc.sqlite"` (SQLite) | For SQLite, specify the full path to the database file.
  77. | [DB_USER](https://docs.djangoproject.com/en/3.1/ref/settings/#user) | `"postgres"` or `"root"`
  78. | [DB_PASSWORD](https://docs.djangoproject.com/en/3.1/ref/settings/#password) | `""` *(empty string)*
  79. | [DB_CONN_MAX_AGE](https://docs.djangoproject.com/en/3.1/ref/settings/#conn-max-age) | `0`
  80. | DB_SSLMODE | `"prefer"` | PostgreSQL-specific, [details](https://blog.github.com/2018-10-21-october21-incident-report/)
  81. | DB_TARGET_SESSION_ATTRS | `"read-write"` | PostgreSQL-specific, [details](https://www.postgresql.org/docs/10/static/libpq-connect.html#LIBPQ-CONNECT-TARGET-SESSION-ATTRS)
  82. | [EMAIL_HOST](https://docs.djangoproject.com/en/3.1/ref/settings/#email-host) | `""` *(empty string)*
  83. | [EMAIL_PORT](https://docs.djangoproject.com/en/3.1/ref/settings/#email-port) | `"587"`
  84. | [EMAIL_HOST_USER](https://docs.djangoproject.com/en/3.1/ref/settings/#email-host-user) | `""` *(empty string)*
  85. | [EMAIL_HOST_PASSWORD](https://docs.djangoproject.com/en/3.1/ref/settings/#email-host-password) | `""` *(empty string)*
  86. | [EMAIL_USE_TLS](https://docs.djangoproject.com/en/3.1/ref/settings/#email-use-tls) | `"True"`
  87. | EMAIL_USE_VERIFICATION | `"True"` | Whether to send confirmation links when adding email integrations
  88. | SITE_ROOT | `"http://localhost:8000"`
  89. | SITE_NAME | `"Mychecks"`
  90. | RP_ID | `None` | Enables WebAuthn support
  91. | MASTER_BADGE_LABEL | `"Mychecks"`
  92. | PING_ENDPOINT | `"http://localhost:8000/ping/"`
  93. | PING_EMAIL_DOMAIN | `"localhost"`
  94. | PING_BODY_LIMIT | 10000 | In bytes. Set to `None` to always log full request body
  95. | APPRISE_ENABLED | `"False"`
  96. | DISCORD_CLIENT_ID | `None`
  97. | DISCORD_CLIENT_SECRET | `None`
  98. | LINENOTIFY_CLIENT_ID | `None`
  99. | LINENOTIFY_CLIENT_SECRET | `None`
  100. | MATRIX_ACCESS_TOKEN | `None`
  101. | MATRIX_HOMESERVER | `None`
  102. | MATRIX_USER_ID | `None`
  103. | PD_VENDOR_KEY | `None`
  104. | PUSHBULLET_CLIENT_ID | `None`
  105. | PUSHBULLET_CLIENT_SECRET | `None`
  106. | PUSHOVER_API_TOKEN | `None`
  107. | PUSHOVER_EMERGENCY_EXPIRATION | `86400`
  108. | PUSHOVER_EMERGENCY_RETRY_DELAY | `300`
  109. | PUSHOVER_SUBSCRIPTION_URL | `None`
  110. | REMOTE_USER_HEADER | `None` | See [External Authentication](#external-authentication) for details.
  111. | SHELL_ENABLED | `"False"`
  112. | SIGNAL_CLI_ENABLED | `"False"`
  113. | SLACK_CLIENT_ID | `None`
  114. | SLACK_CLIENT_SECRET | `None`
  115. | TELEGRAM_BOT_NAME | `"ExampleBot"`
  116. | TELEGRAM_TOKEN | `None`
  117. | TRELLO_APP_KEY | `None`
  118. | TWILIO_ACCOUNT | `None`
  119. | TWILIO_AUTH | `None`
  120. | TWILIO_FROM | `None`
  121. | TWILIO_USE_WHATSAPP | `"False"`
  122. Some useful settings keys to override are:
  123. `SITE_ROOT` is used to build fully qualified URLs for pings, and for use in
  124. emails and notifications. Example:
  125. ```python
  126. SITE_ROOT = "https://my-monitoring-project.com"
  127. ```
  128. `SITE_NAME` has the default value of "Mychecks" and is used throughout
  129. the templates. Replace it with your own name to personalize your installation.
  130. Example:
  131. ```python
  132. SITE_NAME = "My Monitoring Project"
  133. ```
  134. `REGISTRATION_OPEN` controls whether site visitors can create new accounts.
  135. Set it to `False` if you are setting up a private healthchecks instance, but
  136. it needs to be publicly accessible (so, for example, your cloud services
  137. can send pings).
  138. If you close new user registration, you can still selectively invite users
  139. to your team account.
  140. `EMAIL_USE_VERIFICATION` enables/disables the sending of a verification
  141. link when an email address is added to the list of notification methods.
  142. Set it to `False` if you are setting up a private healthchecks instance where
  143. you trust your users and want to avoid the extra verification step.
  144. `PING_BODY_LIMIT` sets the size limit in bytes for logged ping request bodies.
  145. The default value is 10000 (10 kilobytes). You can remove the limit altogether by
  146. setting this value to `None`.
  147. ## Database Configuration
  148. Database configuration is loaded from environment variables. If you
  149. need to use a non-standard configuration, you can override the
  150. database configuration in `hc/local_settings.py` like so:
  151. ```python
  152. DATABASES = {
  153. 'default': {
  154. 'ENGINE': 'django.db.backends.postgresql',
  155. 'NAME': 'your-database-name-here',
  156. 'USER': 'your-database-user-here',
  157. 'PASSWORD': 'your-database-password-here',
  158. 'TEST': {'CHARSET': 'UTF8'},
  159. 'OPTIONS': {
  160. ... your custom options here ...
  161. }
  162. }
  163. }
  164. ```
  165. ## Accessing Administration Panel
  166. healthchecks comes with Django's administration panel where you can manually
  167. view and modify user accounts, projects, checks, integrations etc. To access it,
  168. * if you haven't already, create a superuser account: `./manage.py createsuperuser`
  169. * log into the site using superuser credentials
  170. * in the top navigation, "Account" dropdown, select "Site Administration"
  171. ## Sending Emails
  172. healthchecks must be able to send email messages, so it can send out login
  173. links and alerts to users. Environment variables can be used to configure
  174. SMTP settings, or your may put your SMTP server configuration in
  175. `hc/local_settings.py` like so:
  176. ```python
  177. EMAIL_HOST = "your-smtp-server-here.com"
  178. EMAIL_PORT = 587
  179. EMAIL_HOST_USER = "username"
  180. EMAIL_HOST_PASSWORD = "password"
  181. EMAIL_USE_TLS = True
  182. ```
  183. For more information, have a look at Django documentation,
  184. [Sending Email](https://docs.djangoproject.com/en/1.10/topics/email/) section.
  185. ## Receiving Emails
  186. healthchecks comes with a `smtpd` management command, which starts up a
  187. SMTP listener service. With the command running, you can ping your
  188. checks by sending email messages
  189. to `[email protected]` email addresses.
  190. Start the SMTP listener on port 2525:
  191. $ ./manage.py smtpd --port 2525
  192. Send a test email:
  193. $ curl --url 'smtp://127.0.0.1:2525' \
  194. --mail-from '[email protected]' \
  195. --mail-rcpt '[email protected]' \
  196. -F '='
  197. ## Sending Status Notifications
  198. healtchecks comes with a `sendalerts` management command, which continuously
  199. polls database for any checks changing state, and sends out notifications as
  200. needed. Within an activated virtualenv, you can manually run
  201. the `sendalerts` command like so:
  202. $ ./manage.py sendalerts
  203. In a production setup, you will want to run this command from a process
  204. manager like [supervisor](http://supervisord.org/) or systemd.
  205. ## Database Cleanup
  206. With time and use the healthchecks database will grow in size. You may
  207. decide to prune old data: inactive user accounts, old checks not assigned
  208. to users, records of outgoing email messages and records of received pings.
  209. There are separate Django management commands for each task:
  210. * Remove old records from `api_ping` table. For each check, keep 100 most
  211. recent pings:
  212. ```
  213. $ ./manage.py prunepings
  214. ```
  215. * Remove old records of sent notifications. For each check, remove
  216. notifications that are older than the oldest stored ping for same check.
  217. ```
  218. $ ./manage.py prunenotifications
  219. ```
  220. * Remove user accounts that match either of these conditions:
  221. * Account was created more than 6 months ago, and user has never logged in.
  222. These can happen when user enters invalid email address when signing up.
  223. * Last login was more than 6 months ago, and the account has no checks.
  224. Assume the user doesn't intend to use the account any more and would
  225. probably *want* it removed.
  226. ```
  227. $ ./manage.py pruneusers
  228. ```
  229. * Remove old records from the `api_tokenbucket` table. The TokenBucket
  230. model is used for rate-limiting login attempts and similar operations.
  231. Any records older than one day can be safely removed.
  232. ```
  233. $ ./manage.py prunetokenbucket
  234. ```
  235. * Remove old records from the `api_flip` table. The Flip
  236. objects are used to track status changes of checks, and to calculate
  237. downtime statistics month by month. Flip objects from more than 3 months
  238. ago are not used and can be safely removed.
  239. ```
  240. $ ./manage.py pruneflips
  241. ```
  242. When you first try these commands on your data, it is a good idea to
  243. test them on a copy of your database, not on the live database right away.
  244. In a production setup, you should also have regular, automated database
  245. backups set up.
  246. ## Two-factor Authentication
  247. Healthchecks optionally supports two-factor authentication using the WebAuthn
  248. standard. To enable WebAuthn support, set the `RP_ID` (relying party identifier )
  249. setting to a non-null value. Set its value to your site's domain without scheme
  250. and without port. For example, if your site runs on `https://my-hc.example.org`,
  251. set `RP_ID` to `my-hc.example.org`.
  252. Note that WebAuthn requires HTTPS, even if running on localhost. To test WebAuthn
  253. locally with a self-signed certificate, you can use the `runsslserver` command
  254. from the `django-sslserver` package.
  255. ## External Authentication
  256. HealthChecks supports external authentication by means of HTTP headers set by
  257. reverse proxies or the WSGI server. This allows you to integrate it into your
  258. existing authentication system (e.g., LDAP or OAuth) via an authenticating proxy.
  259. When this option is enabled, **healtchecks will trust the header's value implicitly**,
  260. so it is **very important** to ensure that attackers cannot set the value themselves
  261. (and thus impersonate any user). How to do this varies by your chosen proxy,
  262. but generally involves configuring it to strip out headers that normalize to the
  263. same name as the chosen identity header.
  264. To enable this feature, set the `REMOTE_USER_HEADER` value to a header you wish to
  265. authenticate with. HTTP headers will be prefixed with `HTTP_` and have any dashes
  266. converted to underscores. Headers without that prefix can be set by the WSGI server
  267. itself only, which is more secure.
  268. When `REMOTE_USER_HEADER` is set, Healthchecks will:
  269. - assume the header contains user's email address
  270. - look up and automatically log in the user with a matching email address
  271. - automatically create an user account if it does not exist
  272. - disable the default authentication methods (login link to email, password)
  273. ## Integrations
  274. ### Slack
  275. To enable the Slack "self-service" integration, you will need to create a "Slack App".
  276. To do so:
  277. * Create a _new Slack app_ on https://api.slack.com/apps/
  278. * Add at least _one scope_ in the permissions section to be able to deploy the app in your workspace (By example `incoming-webhook` for the `Bot Token Scopes`
  279. https://api.slack.com/apps/APP_ID/oauth?).
  280. * Add a _redirect url_ in the format `SITE_ROOT/integrations/add_slack_btn/`.
  281. For example, if your SITE_ROOT is `https://my-hc.example.org` then the redirect URL would be
  282. `https://my-hc.example.org/integrations/add_slack_btn/`.
  283. * Look up your Slack app for the Client ID and Client Secret at https://api.slack.com/apps/APP_ID/general? . Put them
  284. in `SLACK_CLIENT_ID` and `SLACK_CLIENT_SECRET` environment
  285. variables.
  286. ### Discord
  287. To enable Discord integration, you will need to:
  288. * register a new application on https://discordapp.com/developers/applications/me
  289. * add a redirect URI to your Discord application. The URI format is
  290. `SITE_ROOT/integrations/add_discord/`. For example, if you are running a
  291. development server on `localhost:8000` then the redirect URI would be
  292. `http://localhost:8000/integrations/add_discord/`
  293. * Look up your Discord app's Client ID and Client Secret. Put them
  294. in `DISCORD_CLIENT_ID` and `DISCORD_CLIENT_SECRET` environment
  295. variables.
  296. ### Pushover
  297. Pushover integration works by creating an application on Pushover.net which
  298. is then subscribed to by Healthchecks users. The registration workflow is as follows:
  299. * On Healthchecks, the user adds a "Pushover" integration to a project
  300. * Healthchecks redirects user's browser to a Pushover.net subscription page
  301. * User approves adding the Healthchecks subscription to their Pushover account
  302. * Pushover.net HTTP redirects back to Healthchecks with a subscription token
  303. * Healthchecks saves the subscription token and uses it for sending Pushover
  304. notifications
  305. To enable the Pushover integration, you will need to:
  306. * Register a new application on Pushover via https://pushover.net/apps/build.
  307. * Within the Pushover 'application' configuration, enable subscriptions.
  308. Make sure the subscription type is set to "URL". Also make sure the redirect
  309. URL is configured to point back to the root of the Healthchecks instance
  310. (e.g., `http://healthchecks.example.com/`).
  311. * Put the Pushover application API Token and the Pushover subscription URL in
  312. `PUSHOVER_API_TOKEN` and `PUSHOVER_SUBSCRIPTION_URL` environment
  313. variables. The Pushover subscription URL should look similar to
  314. `https://pushover.net/subscribe/yourAppName-randomAlphaNumericData`.
  315. ### Signal
  316. Healthchecks uses [signal-cli](https://github.com/AsamK/signal-cli) to send Signal
  317. notifications. Healthcecks interacts with signal-cli over DBus.
  318. To enable the Signal integration:
  319. * Set up and configure signal-cli to listen on DBus system bus ([instructions](https://github.com/AsamK/signal-cli/wiki/DBus-service)).
  320. Make sure you can send test messages from command line, using the `dbus-send`
  321. example given in the signal-cli instructions.
  322. * Set the `SIGNAL_CLI_ENABLED` environment variable to `True`.
  323. ### Telegram
  324. * Create a Telegram bot by talking to the
  325. [BotFather](https://core.telegram.org/bots#6-botfather). Set the bot's name,
  326. description, user picture, and add a "/start" command.
  327. * After creating the bot you will have the bot's name and token. Put them
  328. in `TELEGRAM_BOT_NAME` and `TELEGRAM_TOKEN` environment variables.
  329. * Run `settelegramwebhook` management command. This command tells Telegram
  330. where to forward channel messages by invoking Telegram's
  331. [setWebhook](https://core.telegram.org/bots/api#setwebhook) API call:
  332. ```
  333. $ ./manage.py settelegramwebhook
  334. Done, Telegram's webhook set to: https://my-monitoring-project.com/integrations/telegram/bot/
  335. ```
  336. For this to work, your `SITE_ROOT` needs to be correct and use "https://"
  337. scheme.
  338. ### Apprise
  339. To enable Apprise integration, you will need to:
  340. * ensure you have apprise installed in your local environment:
  341. ```bash
  342. pip install apprise
  343. ```
  344. * enable the apprise functionality by setting the `APPRISE_ENABLED` environment variable.
  345. ### Shell Commands
  346. The "Shell Commands" integration runs user-defined local shell commands when checks
  347. go up or down. This integration is disabled by default, and can be enabled by setting
  348. the `SHELL_ENABLED` environment variable to `True`.
  349. Note: be careful when using "Shell Commands" integration, and only enable it when
  350. you fully trust the users of your Healthchecks instance. The commands will be executed
  351. by the `manage.py sendalerts` process, and will run with the same system permissions as
  352. the `sendalerts` process.
  353. ### Matrix
  354. To enable the Matrix integration you will need to:
  355. * Register a bot user (for posting notifications) in your preferred homeserver.
  356. * Use the [Login API call](https://www.matrix.org/docs/guides/client-server-api#login)
  357. to retrieve bot user's access token. You can run it as shown in the documentation,
  358. using curl in command shell.
  359. * Set the `MATRIX_` environment variables. Example:
  360. ```
  361. MATRIX_HOMESERVER=https://matrix.org
  362. MATRIX_USER_ID=@mychecks:matrix.org
  363. MATRIX_ACCESS_TOKEN=[a long string of characters returned by the login call]
  364. ```
  365. ## Running in Production
  366. Here is a non-exhaustive list of pointers and things to check before launching a Healthchecks instance
  367. in production.
  368. * Environment variables, settings.py and local_settings.py.
  369. * [DEBUG](https://docs.djangoproject.com/en/2.2/ref/settings/#debug). Make sure it is set to `False`.
  370. * [ALLOWED_HOSTS](https://docs.djangoproject.com/en/2.2/ref/settings/#allowed-hosts). Make sure it
  371. contains the correct domain name you want to use.
  372. * Server Errors. When DEBUG=False, Django will not show detailed error pages, and will not print exception
  373. tracebacks to standard output. To receive exception tracebacks in email,
  374. review and edit the [ADMINS](https://docs.djangoproject.com/en/2.2/ref/settings/#admins) and
  375. [SERVER_EMAIL](https://docs.djangoproject.com/en/2.2/ref/settings/#server-email) settings.
  376. Another good option for receiving exception tracebacks is to use [Sentry](https://sentry.io/for/django/).
  377. * Management commands that need to be run during each deployment.
  378. * This project uses [Django Compressor](https://django-compressor.readthedocs.io/en/stable/)
  379. to combine the CSS and JS files. It is configured for offline compression – run the
  380. `manage.py compress` command whenever files in the `/static/` directory change.
  381. * This project uses Django's [staticfiles app](https://docs.djangoproject.com/en/2.2/ref/contrib/staticfiles/).
  382. Run the `manage.py collectstatic` command whenever files in the `/static/`
  383. directory change. This command collects all the static files inside the `static-collected` directory.
  384. Configure your web server to serve files from this directory under the `/static/` prefix.
  385. * Database migration should be run after each update to make sure the database schemas are up to date. You can do that with `./manage.py migrate`.
  386. * Processes that need to be running constantly.
  387. * `manage.py runserver` is intended for development only. Do not use it in production,
  388. instead consider using [uWSGI](https://uwsgi-docs.readthedocs.io/en/latest/) or
  389. [gunicorn](https://gunicorn.org/).
  390. * Make sure the `manage.py sendalerts` command is running and can survive server restarts.
  391. On modern linux systems, a good option is to
  392. [define a systemd service](https://github.com/healthchecks/healthchecks/issues/273#issuecomment-520560304) for it.
  393. * General
  394. * Make sure the database is secured well and is getting backed up regularly
  395. * Make sure the TLS certificates are secured well and are getting refreshed regularly
  396. * Have monitoring in place to be sure the Healthchecks instance itself is operational
  397. (is accepting pings, is sending out alerts, is not running out of resources).