Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/bin/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def get_status(b):
ENABLE_WEB = get_bool("LEEK_ENABLE_WEB")
ENABLE_DDTRACE = get_bool("LEEK_ENABLE_DDTRACE")
LEEK_ES_URL = os.environ.get("LEEK_ES_URL", "http://0.0.0.0:9200")
LEEK_ES_API_KEY = os.environ.get("LEEK_ES_API_KEY", None)
LEEK_ES_IM_ENABLE = get_bool("LEEK_ES_IM_ENABLE", default="false")
LEEK_ES_IM_SLACK_WEBHOOK_URL = os.environ.get("LEEK_ES_IM_SLACK_WEBHOOK_URL")
LEEK_ES_IM_ROLLOVER_MIN_SIZE = os.environ.get("LEEK_ES_IM_ROLLOVER_MIN_SIZE")
Expand Down Expand Up @@ -291,7 +292,7 @@ def ensure_connection(target):

def ensure_es_connection() -> Elasticsearch:
logging.getLogger("elasticsearch").setLevel(logging.ERROR)
conn = Elasticsearch(LEEK_ES_URL)
conn = Elasticsearch(LEEK_ES_URL, api_key=LEEK_ES_API_KEY)
for i in range(10):
if conn.ping():
logging.getLogger("elasticsearch").setLevel(logging.INFO)
Expand Down
1 change: 1 addition & 0 deletions app/leek/api/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def get_bool(env_name, default="false"):

# ES
LEEK_ES_URL = os.environ.get("LEEK_ES_URL")
LEEK_ES_API_KEY = os.environ.get("LEEK_ES_API_KEY", None)
LEEK_ES_DEFAULT_REFRESH_INTERVAL = os.environ.get("LEEK_ES_DEFAULT_REFRESH_INTERVAL", "20s")
LEEK_ES_IM_ENABLE = get_bool("LEEK_ES_IM_ENABLE", default="false")

Expand Down
2 changes: 1 addition & 1 deletion app/leek/api/ext/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class ESExtension(BaseExtension):

def init_app(self, app):
app.extensions["es"] = self
self.connection = Elasticsearch(settings.LEEK_ES_URL)
self.connection = Elasticsearch(settings.LEEK_ES_URL, api_key=settings.LEEK_ES_API_KEY)
logger.info("Connected to elastic search backend!")
1 change: 1 addition & 0 deletions doc/docs/architecture/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Leek components are configured using environment variables.
|:---- | ---- | ---- |
| `LEEK_ENABLE_API` | Whether to enable or disable the API. | false |
| `LEEK_ES_URL` | ElasticSearch index db domain URL | None |
| `LEEK_ES_API_KEY` | ElasticSearch api key | None |
| `LEEK_API_LOG_LEVEL` | Log level, set it to ERROR after making sure that the agent can reach brokers and api. | INFO |
| `LEEK_WEB_URL` | Frontend application url, will be used when constructing slack triggers notifications. | None |
| `LEEK_API_OWNER_ORG` | The owner organization name that can manage leek, it should be domain name for gsuite organizations, and google username for personal account. | None |
Expand Down