Skip to content

Instantly share code, notes, and snippets.

/tmp/sandbox
❯ jruby -v
jruby 9.4.7.0 (3.1.4) 2024-04-29 597ff08ac1 OpenJDK 64-Bit Server VM 17.0.9+9 on 17.0.9+9 +jit [arm64-darwin]
/tmp/sandbox
❯ git clone [email protected]:logstash-plugins/logstash-input-salesforce.git
Cloning into 'logstash-input-salesforce'...
remote: Enumerating objects: 331, done.
remote: Counting objects: 100% (57/57), done.
remote: Compressing objects: 100% (21/21), done.
# env var:
# keystore:
# pipeline.workers = default to cpu cores
❯ docker run docker.elastic.co/logstash/logstash-full:8.16.0-SNAPSHOT sh -c 'rm config/logstash.keystore && echo 1 | bin/logstash -e "" | grep pipeline.workers'
[2024-08-09T16:06:29,979][INFO ][logstash.javapipeline][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>10, [...]
# env var: 2
# keystore:
# pipeline.workers = env var
❯ docker run -e PIPELINE_WORKERS="2" docker.elastic.co/logstash/logstash-full:8.16.0-SNAPSHOT sh -c 'rm config/logstash.keystore && echo 1 | bin/logstash -e "" | grep pipeline.workers'
❯ cat with_copy/Dockerfile
FROM centos:7
COPY logstash-8.13.2-linux-aarch64.tar.gz /tmp/logstash.tar.gz
RUN tar -zxf /tmp/logstash.tar.gz && rm /tmp/logstash.tar.gz
❯ docker build -q with_copy
sha256:fce85351f818038d93afbd4005ff4fe10a2d7771ce1e603a54f91300e4032d1e
❯ docker run -it fce85351f818038d93afbd4005ff4fe10a2d7771ce1e603a54f91300e4032d1e /logstash-8.13.2/bin/logstash -V
❯ for type in inputs filters codecs outputs; do echo "List of $type"; cat ./logstash_node_stats.json | jq -r ".pipelines | map(.plugins.$type)[] | map(.name)[]" | sort | uniq -c | sort -k2; done
List of inputs
1 beats
2 jdbc
1 syslog
1 tcp
List of filters
1 clone
4 date
1 dissect
@jsvd
jsvd / gist:25a83d57eb062a66f970da3fd8a87c42
Created March 12, 2024 11:32
Logstash with verbose:class
This file has been truncated, but you can view the full file.
/tmp/logstash-8.12.2
❯ LS_JAVA_OPTS="-verbose:class" bin/logstash -e "input { generator { count => 1 } } output { stdout {} }"
Using bundled JDK: /tmp/logstash-8.12.2/jdk.app/Contents/Home
exec "/tmp/logstash-8.12.2/jdk.app/Contents/Home/bin/java" -cp "/tmp/logstash-8.12.2/vendor/jruby/lib/jruby.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/checker-qual-3.33.0.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/commons-codec-1.15.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/commons-compiler-3.1.0.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/commons-logging-1.2.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/error_prone_annotations-2.18.0.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/failureaccess-1.0.1.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/google-java-format-1.15.0.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/guava-32.1.2-jre.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/httpclient-4.5.13.jar:/tmp/logstash-8.12.2/logstash-core/lib/jars/httpcore-4.4.14.jar:/tmp/logstash-8.12.2/logstash
require 'socket'
HOST = 'localhost'
PORT = 5555
def connect_and_close
socket = TCPSocket.new(HOST, PORT)
linger = [1,0].pack('ii')
socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, linger)
socket.close
# encoding: utf-8
# JRUBY_OPTS="-J-Xmx4g -J-Xms4g" ruby beats_writer_ssl.rb
require "socket"
require "thread"
require "zlib"
require "json"
require "openssl"
Thread.abort_on_exception = true
HOST="127.0.0.1"
# written for python 2.7
#
# CAKe : CEF Army Knife experiment
# A versatile CEF manipulation and generation tool
#
# Author : Gaetan Cardinal
# cardinal_gaetan |at| yahoo.fr
#
# Version: 0.2
# Updated: Jan 2014
@jsvd
jsvd / script.rb
Last active December 13, 2021 12:16
# encoding: utf-8
# Script to test local Logstash instance for JNDI lookups (Log4j vulnerability)
#
# To run, copy script to Logstash folder and run:
#
# bin/ruby script.rb
#
# Script's steps:
# Step 1: setup environment
require 'openssl'
require 'net/http'
def cert_from_url(url)
txt = Net::HTTP.get(URI(url))
OpenSSL::X509::Certificate.new(txt)
end
LEAF_CERTIFICATE = OpenSSL::X509::Certificate.new %q[
-----BEGIN CERTIFICATE-----