forked from linkedin/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
8,613 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*pyc | ||
*swp | ||
/env | ||
*egg-info | ||
/iris-api/docker/logs | ||
/build | ||
/dist | ||
*swo | ||
.cache | ||
.coverage | ||
htmlcov | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Contribution Agreement | ||
====================== | ||
|
||
As a contributor, you represent that the code you submit is your | ||
original work or that of your employer (in which case you represent you | ||
have the right to bind your employer). By submitting code, you (and, if | ||
applicable, your employer) are licensing the submitted code to LinkedIn | ||
and the open source community subject to the BSD 2-Clause license. | ||
|
||
Responsible Disclosure of Security Vulnerabilities | ||
================================================== | ||
|
||
Please do not file reports on Github for security issues. | ||
Please review the guidelines on at (link to more info). | ||
Reports should be encrypted using PGP (link to PGP key) and sent to | ||
[email protected] preferably with the title "Github linkedin/<project> - <short summary>". | ||
|
||
Tips for Getting Your Pull Request Accepted | ||
=========================================== | ||
|
||
*Note: These are suggestions. Customize as needed.* | ||
|
||
1. Make sure all new features are tested and the tests pass. | ||
2. Bug fixes must include a test case demonstrating the error that it fixes. | ||
3. Open an issue first and seek advice for your change before submitting | ||
a pull request. Large features which have never been discussed are | ||
unlikely to be accepted. **You have been warned.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM ubuntu:16.04 | ||
|
||
RUN apt-get update && apt-get -y dist-upgrade \ | ||
&& apt-get -y install python-pip uwsgi virtualenv sudo python-dev libyaml-dev \ | ||
libsasl2-dev libldap2-dev nginx uwsgi-plugin-python mysql-client \ | ||
&& rm -rf /var/cache/apt/archives/* | ||
|
||
RUN useradd -m -s /bin/bash iris | ||
|
||
COPY setup.py /home/iris/setup.py | ||
COPY docker/entrypoint.py /home/iris/entrypoint.py | ||
ADD docker/daemons /home/iris/daemons | ||
ADD db /home/iris/db | ||
ADD src /home/iris/src | ||
|
||
RUN chown -R iris:iris /home/iris /var/log/nginx /var/lib/nginx \ | ||
&& sudo -Hu iris mkdir -p /home/iris/var/log/uwsgi /home/iris/var/log/nginx /home/iris/var/run \ | ||
&& sudo -Hu iris virtualenv /home/iris/env \ | ||
&& sudo -Hu iris /bin/bash -c 'source /home/iris/env/bin/activate && cd /home/iris && python setup.py install' | ||
|
||
EXPOSE 16649 | ||
|
||
CMD ["bash", "-c", "source /home/iris/env/bin/activate && python /home/iris/entrypoint.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
BSD 2-CLAUSE LICENSE | ||
|
||
Copyright 2017 LinkedIn Corporation. | ||
All Rights Reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
all: serve | ||
|
||
serve: | ||
gunicorn --reload --access-logfile=- -b '0.0.0.0:16649' --worker-class gevent \ | ||
-e CONFIG=./configs/config.dev.yaml \ | ||
iris_api.wrappers.gunicorn:application | ||
|
||
test: | ||
make unit | ||
make e2e | ||
|
||
e2e: | ||
py.test ./test/e2etest.py | ||
|
||
unit: | ||
py.test test | ||
|
||
unit-cov: | ||
py.test --cov-report term-missing --cov=iris_api test | ||
|
||
e2e-cov: | ||
./test/e2etest_coverage.sh | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Copyright 2017 LinkedIn Corporation | ||
All Rights Reserved. | ||
Licensed under the BSD 2-Clause License (the "License"). See License in the project root for license information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Iris-API (and iris-sender) under Docker | ||
====================================== | ||
|
||
### Get started | ||
|
||
Build container. This installs all dependencies as well as copies all iris-api source code. | ||
|
||
docker build -t iris-api . | ||
|
||
Edit iris-api's config file as needed (MySQL and vendor settings and so on): | ||
|
||
vim docker/config/config.yaml | ||
|
||
Run it, with bind mounts to give access to iris api config file | ||
|
||
docker run -p 16649:16649 -v `pwd`/docker/config:/home/iris/config -t iris-api | ||
|
||
You can optionally bind mount log directories for uwsgi/nginx: | ||
|
||
mkdir -p docker/logs/{uwsgi,nginx} | ||
docker run -p 16649:16649 -v `pwd`/docker/config:/home/iris/config \ | ||
-v `pwd`/docker/logs/nginx:/home/iris/var/log/nginx \ | ||
-v `pwd`/docker/logs/uwsgi:/home/iris/var/log/uwsgi -t iris-api | ||
|
||
You can then hit `http://localhost:16649 ` to access iris-api running within the docker. | ||
|
||
### Quick commands | ||
|
||
Check what containers are running: | ||
|
||
docker ps | ||
|
||
Kill and remove a container: | ||
|
||
docker rm -f $ID | ||
|
||
Execute a bash shell inside container while it's running: | ||
|
||
docker exec -i -t $ID /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
Iris API | ||
======== | ||
|
||
Iris API core and sender service | ||
|
||
|
||
Setup database | ||
-------------- | ||
|
||
1. create mysql schema: `mysql -u USER -p < ./db/schema_0.sql` | ||
1. import dummy data: `mysql -u USER -p -o iris < ./db/dummy_data.sql` | ||
|
||
`dummy_data.sql` contains the following entities: | ||
* user `demo` | ||
* team `demo_team` | ||
* application `Autoalerts` with key: `a7a9d7657ac8837cd7dfed0b93f4b8b864007724d7fa21422c24f4ff0adb2e49` | ||
|
||
|
||
Setup dev environment | ||
--------------------- | ||
|
||
1. create & source your virtualenv | ||
1. run `python setup.py develop` | ||
1. run `pip install -r dev_requirements.txt` | ||
1. edit ./configs/config.dev.yaml to setup database credential and other settings | ||
|
||
|
||
Run API server | ||
-------------- | ||
|
||
```bash | ||
make serve | ||
``` | ||
|
||
|
||
Run sender | ||
--------- | ||
|
||
```bash | ||
iris-sender configs/config.dev.yaml | ||
``` | ||
|
||
|
||
Tests | ||
----- | ||
|
||
Run tests: | ||
|
||
```bash | ||
make test # all tests, e2e + unit | ||
make e2e # e2e tests | ||
make unit # unit tests | ||
``` | ||
|
||
Generate test coverage reports: | ||
|
||
```bash | ||
make e2e-cov | ||
make unit-cov | ||
``` | ||
|
||
|
||
Adding new plugins | ||
------------------ | ||
|
||
1. create the plugin file under `src/iris_api/plugis` dir | ||
1. edit `src/iris_api/plugins/__init__.py` to add plugin module to `__all__` list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
server: | ||
host: 127.0.0.1 | ||
port: 16649 | ||
disable_auth: True | ||
role_lookup: dummy | ||
metrics: influx | ||
|
||
# use this for LDAP settings for sync script lookup | ||
# init_config_hook: iris_internal.api.init_config | ||
|
||
#metrics: prometheus | ||
#prometheus: | ||
# iris-sync-targets: | ||
# server_port: 8001 | ||
# iris-sender: | ||
# server_port: 8002 | ||
# | ||
# | ||
|
||
#metrics: influx | ||
#influxdb: | ||
# connect: | ||
# host: localhost | ||
# port: 8086 | ||
# database: iris | ||
|
||
db: &db | ||
conn: | ||
kwargs: | ||
scheme: mysql+pymysql | ||
user: root | ||
password: "" | ||
host: 127.0.0.1 | ||
database: iris | ||
charset: utf8 | ||
str: "%(scheme)s://%(user)s:%(password)s@%(host)s/%(database)s?charset=%(charset)s" | ||
query_limit: 500 | ||
kwargs: | ||
pool_recycle: 3600 | ||
echo: False | ||
pool_size: 100 | ||
max_overflow: 100 | ||
pool_timeout: 60 | ||
sender: | ||
debug: True | ||
host: 127.0.0.1 | ||
port: 2321 | ||
is_master: True | ||
# slaves: | ||
# - host: 127.0.0.1 | ||
# port: 2322 | ||
# - host: 127.0.0.1 | ||
# port: 2323 | ||
|
||
vendors: [] | ||
#- type: iris_slack | ||
# name: slack | ||
# auth_token: '' | ||
# base_url: 'https://slack.com/api/chat.postMessage' | ||
# proxy: *proxy_shared | ||
# message_attachments: | ||
# fallback: 'Iris Alert Fired!' | ||
# color: 'danger' | ||
# pretext: '<!here> _Iris_ _Alert!_' | ||
|
||
# - type: iris_twilio | ||
# name: twilio_1 | ||
# account_sid: '' | ||
# auth_token: '' | ||
# twilio_number: '' | ||
# relay_base_url: '' | ||
|
||
healthcheck_path: /tmp/status | ||
|
||
enable_gmail_oneclick: True | ||
gmail_one_click_url_key: 'foo' | ||
gmail_one_click_url_endpoint: 'http://localhost:16648/api/v0/gmail-oneclick/relay' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
LOCK TABLES `target_type` WRITE; | ||
INSERT IGNORE INTO `target_type` VALUES (2,'team'),(1,'user'); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `target` WRITE; | ||
INSERT IGNORE INTO `target` VALUES (1,'demo',1,1),(2,'abc',1,1),(3,'foo',1,1),(4,'demo_team',2,1),(5,'foo_team',2,1); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `user` WRITE; | ||
INSERT IGNORE INTO `user` VALUES (1),(2),(3); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `mode` WRITE; | ||
INSERT IGNORE INTO `mode` VALUES (26,'call'),(35,'email'),(17,'im'),(8,'sms'); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `priority` WRITE; | ||
INSERT IGNORE INTO `priority` VALUES (8,'urgent',26),(17,'high',8),(26,'medium',35),(35,'low',35); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `target_role` WRITE; | ||
INSERT IGNORE INTO `target_role` VALUES (8,'user',1),(17,'manager',1),(35,'team',2),(44,'oncall',1); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `target_contact` WRITE; | ||
INSERT IGNORE INTO `target_contact` VALUES (1,8,'+1 123-456-7890'),(1,17,'demo'),(1,26,'+1 123-456-7890'),(1,35,'[email protected]'); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `application` WRITE; | ||
INSERT INTO `application` VALUES (8,'Autoalerts','a7a9d7657ac8837cd7dfed0b93f4b8b864007724d7fa21422c24f4ff0adb2e49','{{#context}}\n<div style=\"text-align: center;\">\n <a href=\"{{console_url}}\" style=\"margin-right: 10px;\">{{name}}</a>\n <div style=\"margin-bottom: 10px;\">\n <small>\n <span style=\"margin-right: 10px;\">\n <span class=\"light\">Datacenter:</span> {{fabric}}\n </span>\n <span>\n <span class=\"light\">Zones:</span> {{zones}}\n </span>\n </small>\n </div>\n {{#if nodes}}\n <p><small><span class=\"light\">Nodes:</span> {{#each nodes}} {{this}} {{/each}}</small></p>\n {{/if}}\n {{#if notes}}\n <p>Notes: {{notes}}</p>\n {{/if}}\n </div>\n</div>\n{{/context}}','{{#context}}\n<ul>\n {{#if name}}\n <li data-toggle=\"tooltip\" data-placement=\"top\" title=\"{{name}}\">\n <strong> Name: </strong> {{name}}\n </li>\n {{/if}}\n {{#if filename}}\n <li data-toggle=\"tooltip\" data-placement=\"top\" title=\"{{filename}}\">\n <strong> Dashboard: </strong> {{filename}}\n </li>\n {{/if}}\n {{#if fabric}}\n <li data-toggle=\"tooltip\" data-placement=\"top\" title=\"{{fabric}}\">\n <strong>Fabric: </strong> {{fabric}}\n </li>\n {{/if}}\n {{#if zones}}\n <li data-toggle=\"tooltip\" data-placement=\"top\" title=\"{{zones}}\">\n <strong>Zones: </strong> {{zones}}\n </li>\n {{/if}}\n {{#if nodes}}\n <li>\n <strong>Nodes: </strong>\n <ul>\n {{#each nodes}}\n <li data-toggle=\"tooltip\" data-placement=\"top\" title=\"{{this}}\"> {{this}} </li>\n {{/each}}\n </ul>\n </li>\n {{/if}}\n</ul>\n{{/context}}\n','{\n \"console_url\": \"\",\n \"fabric\": \"DC1\",\n \"filename\": \"dashboard\",\n \"graph_image_url\": \"http://url.example.com/foo\",\n \"metanodes\": [\n [\"execution_time.metanode1\", \"threshold: 72 is greater than the max (65)\"],\n ],\n \"name\": \"Name Of Your Alert\",\n \"nodes\": [\n [\"execution_time.server1.example.com\", \"threshold: 72 is greater than the max (65)\"],\n ],\n \"notes\": \"This is a note\",\n \"zones\": [\"zone1\", \"zone2\"]\n}',0,0),(9,'iris-frontend','fooooo',NULL,NULL,NULL,1,1),(10,'test-app','sdffdssdf',NULL,NULL,NULL,0,0); | ||
UNLOCK TABLES; | ||
|
||
LOCK TABLES `template_variable` WRITE; | ||
INSERT INTO `template_variable` VALUES (1,8,'fabric',0),(2,8,'console_url',0),(3,8,'filename',0),(4,8,'name',0),(5,8,'graph_image_url',0),(7,8,'zones',0),(8,8,'nodes',0),(9,8,'metanodes',0),(10,8,'notes',0); | ||
UNLOCK TABLES; |
Oops, something went wrong.