-
Notifications
You must be signed in to change notification settings - Fork 20
Feature/logstash containerized #734
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3355c19
add logstash and influxdb docker roles, fix strings in stats role
JCLSurf 41af531
correct stats db variable name
JCLSurf 1c123e1
set default for influxdb host
JCLSurf e4a83cb
add container to the correct network
JCLSurf f28c396
change logstash mountpoints
JCLSurf f2aa893
make influxdb_docker role idempotent and remove unneeded options
JCLSurf 5c6c993
refactor logstash file locations
JCLSurf 5efa1ab
fix logstash config dir location
JCLSurf 59280a8
make logstash amount of memory variable
JCLSurf 4543a38
give correct path for files directory
JCLSurf 98929d0
fix hostname for influxdb endpoint in logstash
JCLSurf a6a066b
add credentials to logstash config
JCLSurf fc33aec
change default file locations to the standard paths
JCLSurf cfdc434
add documentation to new roles
JCLSurf 89c57b7
remove unused meta files
JCLSurf be28197
make logstash uid variable, add influxdb backups and continuous queries.
JCLSurf 810206f
fix idempotency
JCLSurf 6e06dc1
cleanup unneeded parts of config file
JCLSurf 246c1e0
fix typo
JCLSurf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,32 @@ | ||
| influxdb_docker | ||
| ========= | ||
|
|
||
| This role deploys a influxdb docker container | ||
|
|
||
| Requirements | ||
| ------------ | ||
|
|
||
| Requires a logstash instance to fill the influxdb. The influxdb instance is used by the stats container. The OpenConext-deploy roles "logstash_docker" and "stats" can provide this. | ||
|
|
||
| Role Variables | ||
| -------------- | ||
|
|
||
| The following variables must be set: | ||
| - influxdb_host (defaults to localhost, is used for setting user permissions within the database) | ||
| - influx_stats_db (name of the database to be created) | ||
| - influxdb_admin_user (admin user for influxdb) | ||
| - influxdb_admin_password (admin password for influxdb, make sure this is securely stored for example in a vault) | ||
| - influxdb_stats_user (user for accessing the database) | ||
| - influxdb_stats_password (user password for influxdb, make sure this is securely stored for example in a vault) | ||
|
|
||
|
|
||
| License | ||
| -------------- | ||
|
|
||
| These files are licensed under version 2.0 of the Apache License, as described in the file [LICENSE](LICENSE). | ||
|
|
||
| Support | ||
| -------------- | ||
|
|
||
| * You can ask questions on the [OpenConext mailing list](https://openconext.org/get-involved/mailing-lists/) | ||
| * Or you can join our [Slack Workspace](https://edu.nl/ocslk) |
This file contains hidden or 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,8 @@ | ||
| --- | ||
| influxdb_host: "localhost" | ||
| # The following variables are not provided but required to run this role. Define these in your inventory or vault: | ||
| # influx_stats_db: | ||
| # influxdb_admin_user: | ||
| # influxdb_admin_password: | ||
| # influxdb_stats_user: | ||
| # influxdb_stats_password: |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,2 @@ | ||
| 0 3 * * * root docker exec influxdb influxd backup -portable /data/influxdb-backup/$(date +\%F) | ||
| 0 4 * * * root find /data/influxdb-backup/ -type f -mtime +1 -exec rm {} \; |
This file contains hidden or 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,89 @@ | ||
| --- | ||
| - name: Create influx user | ||
| ansible.builtin.user: | ||
| name: influxdb | ||
| uid: "1500" | ||
|
|
||
| - name: Ensure required host directories exists | ||
| ansible.builtin.file: | ||
| path: "{{ item }}" | ||
| state: directory | ||
| owner: "influxdb" | ||
| group: "influxdb" | ||
| mode: "0755" | ||
| with_items: | ||
| - "/opt/openconext/influxdb/etc" | ||
| - "/opt/openconext/influxdb/varlib" | ||
| - "/data/influxdb-backup" | ||
|
|
||
| - name: Create influx container | ||
| community.docker.docker_container: | ||
| name: "influxdb" | ||
| image: "influxdb:1.12" | ||
| state: started | ||
| restart_policy: "always" | ||
| recreate: false | ||
| networks: | ||
| - name: "loadbalancer" | ||
| ports: | ||
| - "8086:8086" | ||
| mounts: | ||
| - source: /opt/openconext/influxdb/varlib | ||
| target: /var/lib/influxdb | ||
| type: bind | ||
| - source: /opt/openconext/influxdb/etc | ||
| target: /etc/influxdb | ||
| type: bind | ||
| - source: /data/influxdb-backup | ||
| target: /data/influxdb-backup | ||
| type: bind | ||
| env: | ||
| INFLUXDB_DB: "{{ influx_stats_db }}" | ||
| INFLUXDB_ADMIN_USER: "{{ influxdb_admin_user }}" | ||
| INFLUXDB_ADMIN_PASSWORD: "{{ influxdb_admin_password }}" | ||
| INFLUXDB_READ_USER: "{{ influxdb_stats_user }}" | ||
| INFLUXDB_READ_USER_PASSWORD: "{{ influxdb_stats_password }}" | ||
| INFLUXDB_HTTP_AUTH_ENABLED: "True" | ||
| INFLUXDB_META_DIR: "/var/lib/influxdb/meta" | ||
| INFLUXDB_DATA_DIR: "/var/lib/influxdb/data" | ||
| INFLUXDB_COORDINATOR_WAL_DIR: "/var/lib/influxdb/wal" | ||
|
|
||
| - name: Wait for influx to start | ||
| ansible.builtin.wait_for: | ||
| port: 8086 | ||
| host: localhost | ||
| state: started | ||
| delay: 5 | ||
|
|
||
| - name: Grant stats user required access to InfluxDB database | ||
| ansible.builtin.uri: | ||
| url: "http://{{ influxdb_host }}:8086/query" | ||
| method: POST | ||
| url_username: "{{ influxdb_admin_user }}" | ||
| url_password: "{{ influxdb_admin_password }}" | ||
| force_basic_auth: true | ||
| body_format: form-urlencoded | ||
| body: | ||
| q: 'GRANT ALL PRIVILEGES TO "{{ influxdb_stats_user }}"' | ||
| status_code: 200 | ||
| return_content: true | ||
| register: influxdb_grant | ||
| changed_when: false | ||
| no_log: true | ||
|
|
||
| - name: Import continuous queries through the InfluxDB Docker container | ||
| community.docker.docker_container_exec: | ||
| container: "influxdb" | ||
| command: > | ||
| influx | ||
| -host {{ influxdb_host }} | ||
| -port 8086 | ||
| -username {{ influxdb_admin_user }} | ||
| -password {{ influxdb_admin_password }} | ||
| stdin: "{{ lookup('ansible.builtin.file', 'files/continuous_queries.sql') }}" | ||
| no_log: true | ||
|
|
||
| - name: Create cron file for making the backups and cleaning them up after 7 days | ||
| ansible.builtin.copy: | ||
| src: files/influxdb_backup | ||
| dest: /etc/cron.d/influxdb_backup | ||
This file contains hidden or 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,29 @@ | ||
| logstash_docker | ||
| ========= | ||
|
|
||
| This role deploys a logstash docker container | ||
|
|
||
| Requirements | ||
| ------------ | ||
|
|
||
| Requires some form of input, the filebeat role from OpenConext-deploy can be used for this. Requires a influxdb instance to write to, the OpenConext-deploy role influxdb_container can be used for this. The database must be named "log_logins" for this combination to work. | ||
|
|
||
| Role Variables | ||
| -------------- | ||
|
|
||
| The following variables must be set: | ||
| - logstash_memory_gb: (defaults to 4, can be set to 1 for development/test environments) | ||
| - influx_stats_dbhost: (the host where influxdb runs on, if this runs in a container on the same host provide the name of the container.) | ||
| - influxdb_stats_user: (user that can access the influxdb database) | ||
| - influxdb_stats_password: (password of the user that can access the database, store this securely for example in a vault.) | ||
|
|
||
| License | ||
| -------------- | ||
|
|
||
| These files are licensed under version 2.0 of the Apache License, as described in the file [LICENSE](LICENSE). | ||
|
|
||
| Support | ||
| -------------- | ||
|
|
||
| * You can ask questions on the [OpenConext mailing list](https://openconext.org/get-involved/mailing-lists/) | ||
| * Or you can join our [Slack Workspace](https://edu.nl/ocslk) |
This file contains hidden or 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,6 @@ | ||
| --- | ||
| logstash_memory_gb: 4 | ||
| # The following variables are not provided but required to run this role. Define these in your inventory or vault: | ||
| # influx_stats_dbhost: | ||
| # influxdb_stats_user: | ||
| # influxdb_stats_password: |
This file contains hidden or 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,6 @@ | ||
| input { | ||
| beats { | ||
| port => 5044 | ||
| type => "log" | ||
| } | ||
| } |
This file contains hidden or 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,33 @@ | ||
| filter { | ||
| if [prog] == "EBAUTH" { | ||
| grok { | ||
| patterns_dir => "/etc/logstash/patterns" | ||
| match => { "message" => "%{SYSLOGBASE:syslogbase} %{GREEDYDATA:ebauth}" } | ||
| } | ||
| } | ||
| json { | ||
| source => "ebauth" | ||
| target => "ebauth" | ||
| } | ||
| date { | ||
| match => [ "[ebauth][context][login_stamp]", "yyyy-MM-dd'T'HH:mm:ssZZ" ] | ||
| } | ||
| de_dot { | ||
| } | ||
| mutate { | ||
| remove_field => [ "source" ] | ||
| remove_field => [ "syslogbase" ] | ||
| add_field => {"[month]" => "%{+MM}"} | ||
| add_field => {"[year]" => "%{+YYYY}"} | ||
| } | ||
| fingerprint { | ||
| key => eighiePhie3xiu3boChaekoomai6iiYilux1zoohoh6ahgh9iaphuthaero4ahme | ||
| source => [ "[ebauth][context][user_id]" ] | ||
| method => SHA256 | ||
| target => [ "[ebauth][context][user_id_hashed]" ] | ||
| } | ||
| ruby { | ||
| code => 'quarter = (event.get("month").to_i / 3.0).ceil; | ||
| event.set("quarter",quarter)' | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| # JVM configuration | ||
|
|
||
| # Xms represents the initial size of total heap space | ||
| # Xmx represents the maximum size of total heap space | ||
|
|
||
| -Xms2g | ||
| -Xmx2g | ||
|
|
||
| ################################################################ | ||
| ## Expert settings | ||
| ################################################################ | ||
| ## | ||
| ## All settings below this section are considered | ||
| ## expert settings. Don't tamper with them unless | ||
| ## you understand what you are doing | ||
| ## | ||
| ################################################################ | ||
|
|
||
| ## GC configuration | ||
| # -XX:+UseParNewGC #Option does not exist | ||
| # -XX:+UseConcMarkSweepGC | ||
| # -XX:CMSInitiatingOccupancyFraction=75 | ||
| # -XX:+UseCMSInitiatingOccupancyOnly | ||
|
|
||
| ## Locale | ||
| # Set the locale language | ||
| #-Duser.language=en | ||
|
|
||
| # Set the locale country | ||
| #-Duser.country=US | ||
|
|
||
| # Set the locale variant, if any | ||
| #-Duser.variant= | ||
|
|
||
| ## basic | ||
|
|
||
| # set the I/O temp directory | ||
| #-Djava.io.tmpdir=$HOME | ||
|
|
||
| # set to headless, just in case | ||
| -Djava.awt.headless=true | ||
|
|
||
| # ensure UTF-8 encoding by default (e.g. filenames) | ||
| -Dfile.encoding=UTF-8 | ||
|
|
||
| # use our provided JNA always versus the system one | ||
| #-Djna.nosys=true | ||
|
|
||
| # Turn on JRuby invokedynamic | ||
| -Djruby.compile.invokedynamic=true | ||
| # Force Compilation | ||
| -Djruby.jit.threshold=0 | ||
|
|
||
| ## heap dumps | ||
|
|
||
| # generate a heap dump when an allocation from the Java heap fails | ||
| # heap dumps are created in the working directory of the JVM | ||
| -XX:+HeapDumpOnOutOfMemoryError | ||
|
|
||
| # specify an alternative path for heap dumps | ||
| # ensure the directory exists and has sufficient space | ||
| #-XX:HeapDumpPath=${LOGSTASH_HOME}/heapdump.hprof | ||
|
|
||
| ## GC logging | ||
| #-XX:+PrintGCDetails | ||
| #-XX:+PrintGCTimeStamps | ||
| #-XX:+PrintGCDateStamps | ||
| #-XX:+PrintClassHistogram | ||
| #-XX:+PrintTenuringDistribution | ||
| #-XX:+PrintGCApplicationStoppedTime | ||
|
|
||
| # log GC status to a file with time stamps | ||
| # ensure the directory exists | ||
| #-Xloggc:${LS_GC_LOG_FILE} | ||
|
|
||
| # Entropy source for randomness | ||
| -Djava.security.egd=file:/dev/urandom |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moet deze niet tussen de 5 en 6000 of was daar iets mee?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Voor influxdb hadden we gezegd om dit zo te laten voor nu, gezien dit niet makkelijk om te zetten was naar een gewenst uid en al wel als non-root draait.