Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Pipeline Extensions #121

Merged
merged 46 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a17fb6c
[WIP] Log Pipeline Extensions
Apr 28, 2017
54ad6a9
Provide build.yml instead build.sh for log-api
Jul 19, 2017
eae9442
Fixed tags for monasca-log-api
Jul 19, 2017
e66b065
Make log-api image compact
Jul 19, 2017
2ccf9f3
Added build.yml to several log-* component
Jul 19, 2017
69443d9
Make monasca-log-* images compact
Jul 19, 2017
e2ef4cc
Change references to actual images
Jul 19, 2017
3c24195
Make enabling/disabling monasca-kibana-plugin
Jul 19, 2017
fa97e54
Added build.yml to hook up CI
Jul 19, 2017
98e344e
Lower the output of logs from kibana image build
Jul 19, 2017
1fa5d4c
Adjusting monasca-log-api image to monasca-api one
Jul 21, 2017
8c4c6e9
Removed deprecated build scripts
Jul 31, 2017
5bc0e08
Changed namespace of Docker images
Jul 31, 2017
d84a24e
Changed LOG_API_PORT variable name
Jul 31, 2017
576fe01
Add README.md details
Jul 31, 2017
41653b7
Fix links
Jul 31, 2017
7cdc977
Provide docs and rename elasticsearch-tpl
Jul 31, 2017
d13b386
Get template name from the filename
Jul 31, 2017
cd56224
Kibana documentation
Aug 1, 2017
0c67302
Missing link in kibana docs
Aug 1, 2017
d302790
Documentation for log-metrics
Aug 1, 2017
84e4b2d
Documentation updated
Aug 2, 2017
aea2578
Added usage & tags for elasticsearch-init
Aug 2, 2017
7f43c75
Fixed tag on elasticsearch-init
Aug 2, 2017
74f2c1c
Fix invalid tag for log-transformer
Aug 3, 2017
c9fa674
Fix docs
Aug 3, 2017
7b3258b
Revert modifications in docker-compose.yml
Aug 3, 2017
40eba3b
Use base monasca/python to build log-api
Aug 7, 2017
1b764a5
Remove unused configuration file
Aug 7, 2017
f3a959b
Add installing gunicorn
Aug 7, 2017
086949b
Merge branch 'master' into log-pipeline
kornicameister Aug 8, 2017
29e0a16
Merge branch 'master' into log-pipeline
kornicameister Aug 11, 2017
45f3454
Adjusted build.yml approach
Aug 11, 2017
b0f472c
Removed duplicated comment
Aug 11, 2017
0a421b8
Merge branch 'master' into log-pipeline
kornicameister Aug 14, 2017
25052ca
Have log topic creation in own container
Aug 14, 2017
b365dd9
Removed [email protected]
Aug 14, 2017
f8f3b1a
Removed circular dependency
Aug 14, 2017
e0dc572
Fix typo in port variable
Aug 14, 2017
187869e
Fix typo in path for /wait-for
Aug 14, 2017
31d07c6
Fix syntax error and bad nc address
Aug 14, 2017
98ff7b7
Fix uploading the TPL to ElasticSearch
Aug 14, 2017
49f1d2a
Merge branch 'master' into log-pipeline
kornicameister Aug 16, 2017
17792dd
Add memcached for log-api
Aug 16, 2017
454dc8a
Merge branch 'master' into log-pipeline
kornicameister Aug 17, 2017
ea01a94
Merge branch 'master' into log-pipeline
timothyb89 Aug 21, 2017
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
9 changes: 9 additions & 0 deletions elasticsearch-init/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM appropriate/curl

ENV ELASTICSEARCH_URI=elasticsearch:9200 \
ELASTICSEARCH_TIMEOUT=60

COPY wait-for.sh upload.sh /
RUN chmod +x /wait-for.sh /upload.sh

ENTRYPOINT /wait-for.sh ${ELASTICSEARCH_URI} && /upload.sh
41 changes: 41 additions & 0 deletions elasticsearch-init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
elasticsearch-init
==================

A container for loading the templates to ElasticSearch.

Tags
----

**elasticsearch-init** uses simple [SemVer][3] tags as follows:

* `0.0.1` - `latest`

Usage
-----

**elasticsearch-init** leverages the [Docker volumes][1]. Each template,
that image is supposed to upload to [ElasticSearch][2], is represented as single file
mounted to ```/templates/``` directory inside the container.
Another point, to keep in mind, is that template uploading requires also a **template name**.
That bit is equal to the filename that holds the template. For instance:

```docker run -v ./tpls/logs.json:/templates/logs -l elasticsearch monasca/elasticsearch-init```

means that:

* content of ```/template/logs``` will be uploaded to [ElasticSearch][2]
* template name will be ```logs```

Configuration
-------------

A number of environment variables can be passed to the container:

| Variable | Default | Description |
|---------------------------|--------------|-----------------------------------|
| `ELASTICSEARCH_URI` | `elasticsearch:9200` | URI to connect to ES |
| `ELASTICSEARCH_TIMEOUT` | `60` | How long to wait for ElasticSearch connection |

[1]: https://docs.docker.com/engine/tutorials/dockervolumes/
[2]: https://hub.docker.com/_/elasticsearch/
[3]: http://semver.org/
5 changes: 5 additions & 0 deletions elasticsearch-init/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repository: monasca/elasticsearch-init
variants:
- tag: 0.0.1
aliases:
- :latest
27 changes: 27 additions & 0 deletions elasticsearch-init/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

TPL_DIR=/templates

_get_tpl_name_from_file() {
local tpl=$1
local tpl_name=$(basename $tpl)
echo $tpl_name
}

if [ ! -d $TPL_DIR ]; then
echo "No templates mounted"
exit 0
else
TPLS=$(ls $TPL_DIR)
fi

for template in $TPLS; do

echo "Handling template file $template"
tpl_name=`_get_tpl_name_from_file $template`

curl -XPUT --retry 2 --retry-delay 2 $ELASTICSEARCH_URI/_template/${tpl_name} -d @$TPL_DIR/$template

done


15 changes: 15 additions & 0 deletions elasticsearch-init/wait-for.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

: ${SLEEP_LENGTH:=2}

wait_for() {
echo Waiting for $1 to listen on $2...
while ! nc -z $1 $2; do echo sleeping; sleep $SLEEP_LENGTH; done
}

for var in "$@"
do
host=${var%:*}
port=${var#*:}
wait_for $host $port
done
63 changes: 63 additions & 0 deletions elasticsearch-templates/logs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"order" : 0,
"template" : "*",
"settings" : {
"index.refresh_interval" : "5s",
"index" : {
"analysis": {
"analyzer" : {
"no_token" : {
"type" : "custom",
"tokenizer" : "keyword",
"filter" : "lowercase"
}
}
}
}
},
"mappings" : {
"_default_" : {
"dynamic_templates" : [ {
"message_field" : {
"mapping" : {
"index" : "analyzed",
"omit_norms" : true,
"type" : "string"
},
"match_mapping_type" : "string",
"match" : "message"
}
}, {
"string_fields" : {
"mapping" : {
"analyzer" : "no_token",
"omit_norms" : true,
"type" : "string"
},
"match_mapping_type" : "string",
"match" : "*"
}
} ],
"properties" : {
"geoip" : {
"dynamic" : true,
"properties" : {
"location" : {
"type" : "geo_point"
}
},
"type" : "object"
},
"@version" : {
"index" : "not_analyzed",
"type" : "string"
}
},
"_all" : {
"enabled" : true,
"omit_norms" : true
}
}
},
"aliases" : { }
}
43 changes: 43 additions & 0 deletions kibana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
ARG KIBANA_VERSION="4.6.3"

FROM node:4-alpine

ARG KIBANA_PLUGIN_VER=""
ARG KIBANA_PLUGIN_REPO=https://github.com/openstack/monasca-kibana-plugin.git
ARG KIBANA_PLUGIN_BRANCH=master

WORKDIR /mkp/

ARG REBUILD_PLUGIN_DEPS=1
RUN apk add --no-cache --virtual build-dep git rsync

ARG REBUILD_PLUGIN_PLUGIN=1
RUN git clone $KIBANA_PLUGIN_REPO --depth 1 --branch $KIBANA_PLUGIN_BRANCH monasca-kibana-plugin && \
cd monasca-kibana-plugin && \
npm install --quiet && \
npm run package --quiet && \
KIBANA_PLUGIN_VER=$(node -e "console.log(require('./package.json').version)") && \
mv target/monasca-kibana-plugin-${KIBANA_PLUGIN_VER}.tar.gz /monasca-kibana-plugin.tar.gz && \
cd / && \
rm -rf /mpk/monasca-kibana-plugin && \
apk del build-dep

FROM kibana:${KIBANA_VERSION}

ENV KEYSTONE_URI=keystone:5000 \
MONASCA_PLUGIN_ENABLED=False

WORKDIR /

ARG REBUILD_FILES=1
COPY --from=0 /monasca-kibana-plugin.tar.gz .
COPY wait-for plugin_config start /
RUN chmod +x /wait-for /plugin_config /start

ARG REBUILD_INSTALL_PLUGIN=1
RUN /plugin_config && \
kibana plugin -r monasca-kibana-plugin && \
kibana plugin -i monasca-kibana-plugin -u file:///monasca-kibana-plugin.tar.gz && \
rm -rf /monasca-kibana-plugin.tar.gz

CMD /start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ENTRYPOINT if you don't want developers to change the executable that is run when the container starts. Prefer ENTRYPOINT than CMD when building executable Docker image

42 changes: 42 additions & 0 deletions kibana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Kibana 4 with monasca-kibana-plugin
===================================

Image extends official [Kibana image][1] with [monasca-kibana-plugin][2].
For more details about the aformentioned plugin, please visit plugin's
[repository][2].

Tags
----

Tags in this image match tags in the official [Kibana image][1].
This is dictated by the fact that plugin should be build for specific
Kibana version. Each tag includes also ``KIBANA_PLUGIN_BRANCH`` information
detail. Final tag is represented as ``{KIBANA_VERSION}-{KIBANA_PLUGIN_BRANCH}``.
That said, tagging presents as follows:

* `4.6.3-master` [`4.6-master`, `4-master`] - corresponds to **Kibana 4.6.3**
[monasca-kibana-plugin][2] build from **master** branch.

Configuration
-------------

| Variable | Default | Description |
|--------------------------------|-----------------|-----------------------------------|
| `KEYSTONE_URI` | `keystone:5000` | An URI to Keystone Admin Endpoint |
| `MONASCA_PLUGIN_ENABLED` | `False` | Should the plugin be enabled or disabled |

Usage
-----

To use this image, first you need to deploy [ElasticSearch][3] and [Keystone][4].

Keystone is required only if ``MONASCA_PLUGIN_ENABLED``
is set to ``True``

Once prerequisites are met, image can ba launched, for example, with:
```docker run -it --rm -l elasticsearch monasca/kibana:4.6.3-master```

[1]: https://hub.docker.com/r/library/kibana
[2]: https://github.com/openstack/monasca-kibana-plugin
[3]: https://hub.docker.com/r/library/elasticsearch
[4]: https://github.com/monasca/monasca-docker/keystone
10 changes: 10 additions & 0 deletions kibana/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repository: monasca/kibana
variants:
- tag: latest
aliases:
- :4.6.3-master
- :4.6-master
- :4-master
args:
KIBANA_VERSION: 4.6.3
KIBANA_PLUGIN_BRANCH: master
7 changes: 7 additions & 0 deletions kibana/plugin_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

echo "#monasca-kibana-plugin
monasca-kibana-plugin.auth_uri: http://${KEYSTONE_URI}
monasca-kibana-plugin.enabled: False
monasca-kibana-plugin.cookie.isSecure: False
" >> /opt/kibana/config/kibana.yml
11 changes: 11 additions & 0 deletions kibana/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

sed -e "
s|monasca-kibana-plugin.enabled:\sFalse|monasca-kibana-plugin.enabled: ${MONASCA_PLUGIN_ENABLED}|g;
" -i /opt/kibana/config/kibana.yml

if [ $MONASCA_PLUGIN_ENABLED == True ]; then
/wait-for $KEYSTONE_URI -- kibana
else
kibana
fi
Loading