Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.
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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
language: python
sudo: required
services:
- docker
python:
- "2.7"
install: "pip install -r dev-requirements.pip"
script: pylint lecli && py.test tests
script:
- pylint lecli && py.test tests
- cd docker && docker-compose run lecli
1 change: 1 addition & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root/.config/lecli/config.ini
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:2.7-slim-jessie

WORKDIR /usr/src/app

RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*

COPY . .
RUN pip install --no-cache-dir -r requirements.txt

RUN cp logentries_tail.sh /usr/bin/letail
RUN chmod +x /usr/bin/letail

CMD [ "lecli", "--version" ]
24 changes: 24 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logentries CLI Docker container
A simply container with lecli installed

## setup
`cp root/.config/config.ini.sample cp root/.config/config.ini`

then edit `root/.config/config.ini` and add your logentries api keys

## lecli arbitrary command
`docker-compose run --rm lecli lecli {lecli command args}`

## test if api keys are working
`docker-compose run --rm lecli lecli get apikeys`

## live tail
`docker-compose run --rm lecli letail {logs_name}`

## tested on
ubuntu 16.04 LTS

Docker version 17.05.0-ce, build 89658be

docker-compose version 1.17.1, build 6d101fb

8 changes: 8 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
lecli:
build: .
volumes:
- ./root/.config/lecli/config.ini:/root/.config/lecli/config.ini
dns:
- 8.8.8.8
33 changes: 33 additions & 0 deletions docker/logentries_tail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

display_usage() {
echo "Require JQ(https://stedolan.github.io/jq/) and lecli(https://github.com/rapid7/lecli)"
echo -e "\nUsage:\n ./logentries_tail.sh [logs_name] \n"
echo -e "\nUsage:\n ./logentries_tail.sh my_production_logs_name \n"
}

# if less than two arguments supplied, display usage
if [ $# -le 0 ]
then
display_usage
exit 1
fi

# check whether user had supplied -h or --help . If yes display usage
if [[ ( $# == "--help") || $# == "-h" ]]
then
display_usage
exit 0
fi

logs_name=$1

echo -e "tail of ${logs_name}"

# https://github.com/stedolan/jq/issues/1124#issuecomment-205346895
jq_logs_key_query=(jq -r '.logsets[] | select(has("logs_info")) | select(.logs_info | length > 0) | .logs_info[] | select(.name | contains("'${logs_name}'") ) .id')
logs_key=`lecli get logsets | "${jq_logs_key_query[@]}" | uniq | sort | paste -s -`

echo -e "${logs_name} log key: ${logs_key}\n"

lecli tail events ${logs_key}
1 change: 1 addition & 0 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logentries-lecli
11 changes: 11 additions & 0 deletions docker/root/.config/lecli/config.ini.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Auth]
account_resource_id =
owner_api_key_id =
owner_api_key =
rw_api_key =
ro_api_key =

[Cli_Favorites]

[Url]
api_url = https://rest.logentries.com