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

Update elk docker image and swap out logstash #26

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

SwooshyCueb
Copy link
Member

Updating this docker image as part of the effort to figure out what's going on with our audit plugin training setup.

Still a work-in-progress. Should probably be using alpine or something instead of relying on systemd.
Using elasticsearch 7 for now, as the kibana in the repo for elasticsearch 8 does not support importing json saved objects.

@trel
Copy link
Member

trel commented Jun 15, 2022

oh interesting - how would one not have to build a dashboard by hand... must be some way to import a thing...

but yes, any progress is good. we'll get it built and tried soon enough.

@SwooshyCueb
Copy link
Member Author

Yeah, they have their own ndjson format we can export with 7 and import into 8. Haven't gotten that far yet though.

@trel
Copy link
Member

trel commented Jun 16, 2022

Ah, very good. We do love a nice text format.

@SwooshyCueb
Copy link
Member Author

Updated container to run the still-relevant bits of the old startup script and create the index pattern, visualization objects, and dashboard automatically on first run.
Still on elk 7 for now. Now that we have a good saved object payload for 7, updating to 8 shouldn't take very long.
I would still like to move away from using systemd in the container at some point, but that's lower priority than just getting everything updated and fixing the amqp header issue.

@SwooshyCueb
Copy link
Member Author

Updated container to elk 8

@trel
Copy link
Member

trel commented Jun 28, 2022

awesome - will definitely need a walkthrough/demo of this.

@SwooshyCueb SwooshyCueb changed the title [WIP] Update elk docker image Update elk docker image Jul 4, 2022
@SwooshyCueb SwooshyCueb changed the title Update elk docker image Update elk docker image and swap out logstash Jul 4, 2022
@SwooshyCueb SwooshyCueb marked this pull request as ready for review July 4, 2022 17:01
@SwooshyCueb
Copy link
Member Author

Swapped logstash for a python script.
Works perfectly with 4.2.11 now. Haven't tested with 4.3 yet as I'm having trouble getting it spun up in a container.

@SwooshyCueb
Copy link
Member Author

For 4.3.0, four of the visualizations in the dashboard were empty, so I pointed them at a different rule name.
audit_pep_auth_agent_auth_request_pre to audit_pep_api_authenticate_pre

I think this will make the container incompatible with 4.2, but now it works with 4.3.0.
I'm not going to squash this commit, as it might be useful to have the 4.2-compatible ndjson in the git history.

@korydraughn
Copy link

korydraughn commented Jul 9, 2022

So the only difference between 4.2 and 4.3 is the PEP names.

We can make the ndjson file mountable (-v) and require the admin to use the correct file based on the version of iRODS. We'd include ndjson files for 4.2 and 4.3 that live beside the docker file. For example, the irods_audit_elk_stack directory could contain the following:

  • Dockerfile
  • example_kibana_dashboard_v4.2.ndjson
  • example_kibana_dashboard_v4.3.ndjson

Doing that allows us to build a single docker image that supports 4.2 and 4.3. docker-compose would also be supported.

The training slides would require trivial tweaks to sync with this scheme.

@trel
Copy link
Member

trel commented Jul 9, 2022

this is quite promising.

@SwooshyCueb
Copy link
Member Author

I'm not a fan of that particular solution. I think there's a way we can set up the visualizations to look for either pep name, that way we can have a single ndjson for both 4.2 and 4.3 with no volume mounting needed

@korydraughn
Copy link

Are you saying you think there's native support for conditionally doing this in kibana/ndjson/etc?

If yes, I agree that would likely be the better approach, especially if it is simple to grasp (i.e. fewer moving parts). Anything more complicated than a volume mount is probably the wrong way to go.

Eventually, the things related to 4.2 will be dropped leaving only 4.3 (hopefully sooner than later). Keeping that in mind while we discuss the pros/cons of each solution for this will help us make the correct decision.

@SwooshyCueb
Copy link
Member Author

Are you saying you think there's native support for conditionally doing this in kibana/ndjson/etc?

Yes, and I've just pushed up the new ndjson. This container should now work fine with 4.2 and 4.3.0.

@korydraughn
Copy link

Nice! Will take a look.

Was there anything you noticed that we need to keep an eye out for in the future?

@korydraughn
Copy link

We also need to document (for our future selves) how to tweak the ndjson file.

You could include a README in the irods_audit_elk_stack directory that captures those steps. It could also reference the kibana/elastic docs for whatever version you used to make this all work.

@SwooshyCueb
Copy link
Member Author

SwooshyCueb commented Jul 12, 2022

Was there anything you noticed that we need to keep an eye out for in the future?

Not so much stuff we need to look out for, but stuff we need to do.

We also need to document (for our future selves) how to tweak the ndjson file.

Yes, and how to update it for newer versions of kibana.

You could include a README in the irods_audit_elk_stack directory that captures those steps. It could also reference the kibana/elastic docs for whatever version you used to make this all work.

Roger dodger.

@SwooshyCueb
Copy link
Member Author

SwooshyCueb commented Jul 21, 2022

Considering how long it takes me to write good documentation for this kind of thing, I decided it would be faster to go ahead and rip systemd out of the container instead of documenting the jank that comes from running systemd in a container for our use case. It ended up taking way longer than I anticipated to update the Kibana init.d script, but I still think this was the correct decision.

I've pushed this up now, along with some small container optimizations and a WIP of the README I'm working on.

Getting away from systemd allows us to perform in the Dockerfile all the first-time setup previously handled by firstrun.sh.
Additionally, the container entrypoint now takes an optional --es-java-heap-size argument to set the Elasticsearch Java heap size, with a default of 512m.

@korydraughn
Copy link

Should we start reviewing this or wait until the PR status changes from "draft"?

@SwooshyCueb
Copy link
Member Author

Review away! Everything is done except the README

Copy link

@korydraughn korydraughn left a comment

Choose a reason for hiding this comment

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

Very nice!

The README made me delete some of my comments, so good stuff.

irods_audit_elk_stack/Dockerfile Outdated Show resolved Hide resolved
irods_audit_elk_stack/Dockerfile Outdated Show resolved Hide resolved
irods_audit_elk_stack/Dockerfile Outdated Show resolved Hide resolved
irods_audit_elk_stack/Dockerfile Show resolved Hide resolved
irods_audit_elk_stack/README.md Outdated Show resolved Hide resolved
irods_audit_elk_stack/elasticsearch/elasticsearch.init Outdated Show resolved Hide resolved
irods_audit_elk_stack/elasticsearch/elasticsearch.yml Outdated Show resolved Hide resolved
irods_audit_elk_stack/kibana/kibana.init Outdated Show resolved Hide resolved
irods_audit_elk_stack/not-logstash/not-logstash.init Outdated Show resolved Hide resolved
irods_audit_elk_stack/not-logstash/not-logstash.py Outdated Show resolved Hide resolved
@SwooshyCueb
Copy link
Member Author

A humorous (to me) observation:
While it is not uncommon for my PRs to contain multiple typos prior to review, these typos are usually my own doing.
In this PR, most of the typos are from the vendor-provided files on which the init.d scripts and configuration files are based.

@SwooshyCueb SwooshyCueb marked this pull request as ready for review August 1, 2022 14:10
@SwooshyCueb SwooshyCueb force-pushed the elk-upd.main branch 2 times, most recently from f83170b to 73e8347 Compare August 2, 2022 14:55
- Updated to elk 8
- Loads of cleanup
- Swapped logstash for a python script
- New startup script sets up the kibana index pattern and dashboard
- Dashboard visualization now look for both 4.2 and 4.3 PEP names
- Must be run with --privileged

Squashed commit: [irods#28] Remove systemd from elk container
Copy link

@korydraughn korydraughn left a comment

Choose a reason for hiding this comment

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

Ship it!

@SwooshyCueb
Copy link
Member Author

Who needs to be poked to get this merged?

@korydraughn
Copy link

@alanking ping!

@alanking
Copy link

alanking commented Aug 2, 2022

Now watching this repo :)

@alanking alanking merged commit 2319731 into irods:main Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants