Skip to content

Commit

Permalink
Clean build of syslog-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Faircloth committed Jun 28, 2019
1 parent c59c14e commit 683bd9f
Show file tree
Hide file tree
Showing 21 changed files with 612 additions and 573 deletions.
3 changes: 3 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

162 changes: 104 additions & 58 deletions .idea/workspace.xml

Large diffs are not rendered by default.

48 changes: 46 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,51 @@ services:
build: ./tests
links:
- splunk
syslog-ng:
image: rfaircloth/scs:develop
build: ./package
hostname: syslog-ng
ports:
- "514"
- "601"
- "514/udp"
- "5514"
- "5514/udp"
stdin_open: true
tty: true
links:
- splunk
environment:
- SPLUNK_HEC_URL=https://splunk:8088/services/collector/event","https://splunk:8088/services/collector/event
- SPLUNK_HEC_STATSURL=https://splunk:8088/services/collector/event
- SPLUNK_HEC_TOKEN=a778f63a-5dff-4e3c-a72c-a03183659e94
- SPLUNK_CONNECT_METHOD=hec
- SPLUNK_DEFAULT_INDEX=main
- SPLUNK_METRICS_INDEX=metrics
# logging:
# driver: splunk
# options:
# splunk-token: a778f63a-5dff-4e3c-a72c-a03183659e94
# splunk-url: https://splunk:8088/services/collector/event
# splunk-index: main
# splunk-insecureskipverify: true
# splunk-verify-connection: false
splunk:
image: splunk/splunk:latest
syslog:
build: ./package
hostname: splunk
ports:
- "8000:8000"
- "8088:8088"
- "8089:8089"
environment:
- SPLUNK_HEC_TOKEN=a778f63a-5dff-4e3c-a72c-a03183659e94
- SPLUNK_PASSWORD=Changed@11
- SPLUNK_START_ARGS=--accept-license
# logging:
# driver: splunk
# options:
# splunk-token: a778f63a-5dff-4e3c-a72c-a03183659e94
# splunk-url: https://splunk:8088/services/collector/event
# splunk-index: main
# splunk-insecureskipverify: true
# splunk-verify-connection: false
24 changes: 15 additions & 9 deletions package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,28 @@ RUN cd /tmp ;\
yum install epel-release-latest-7.noarch.rpm -y ;\
rm epel-release-latest-7.noarch.rpm ;\
rpm --import https://packages.confluent.io/rpm/5.2/archive.key ;\
yum install tzdata libdbi libsecret libxml2 sqlite tcp_wrappers librdkafka \
rh-python36 rh-python36-python-tools libcurl ivykis -y;\
echo source scl_source enable rh-python36 >>/etc/profile.d/enablepython36.sh
yum install gcc tzdata libdbi libsecret libxml2 sqlite tcp_wrappers librdkafka \
rh-python36 rh-python36-python-tools libcurl ivykis scl-utils tcp_wrappers-libs -y;\
echo source scl_source enable rh-python36 >>/etc/profile.d/enablepython36.sh ;\
source scl_source enable rh-python36 ;\
pip install dumb-init


COPY --from=0 /opt/syslog-ng /opt/syslog-ng
COPY scripts/* /opt/syslog-ng/sbin/
COPY etc/* /opt/syslog-ng/etc
COPY sbin/* /sbin/
COPY scripts/splunkmetrics.sh /opt/syslog-ng/sbin/splunkmetrics.sh
COPY scripts/switch_transport.sh /opt/syslog-ng/sbin/switch_transport.sh
COPY etc/syslog-ng.conf /opt/syslog-ng/etc/syslog-ng.conf
COPY etc/conf.d /opt/syslog-ng/etc/conf.d
COPY sbin/entrypoint.sh /sbin/entrypoint.sh

RUN /opt/syslog-ng/sbin/syslog-ng -t
RUN source scl_source enable rh-python36 ;/opt/syslog-ng/sbin/syslog-ng -V
RUN source scl_source enable rh-python36 ;/opt/syslog-ng/sbin/syslog-ng -t

ENV DEBCONF_NONINTERACTIVE_SEEN=true
ENV SPLUNK_CONNECT_METHOD=uf
ENV SPLUNK_CONNECT_METHOD=hec

EXPOSE 514
EXPOSE 601/tcp
EXPOSE 6514/tcp

ENTRYPOINT ["/sbin/entrypoint.sh", "--"]
#ENTRYPOINT ["/sbin/entrypoint.sh", "--"]
251 changes: 251 additions & 0 deletions package/etc/conf.d/b_destinations.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# ===============================================================================================
# Destination Blocks (functions) for Splunk destinations
# Block argument defaults are defined in main syslog-ng.conf file
# Additional indexed fields (based on syslog-ng macros) can be added to the "with_metadata" blocks
# for both HEC and Kafka.
# Format is "fields.<splunk_indexed_field>=<syslog-ng macro>"
# ===============================================================================================

# ===============================================================================================
# blocks for file destination (for use with the Splunk Universal Forwarder)
# ===============================================================================================

# ===============================================================================================
# Logfile Local Defaults:
# vendor: unassigned
# message: suffix for log file names; "messages"
# ===============================================================================================

block destination d_splunk_logfile(category("")
vendor("unassigned")
filename("messages")
use_template(`splunk-default-template`)
) {
file("`splunk-log-root`/`category`/$(lowercase \"${LOGHOST}\")/`vendor`/$(lowercase \"${HOST}\")/${YEAR}.${MONTH}.${DAY}.${HOUR}-`filename`"
template(`use_template`)
flush-lines(0)
create-dirs(yes)
dir_owner(`splunk-user`)
dir_group(`splunk-group`)
dir_perm(0700)
owner(`splunk-user`)
group(`splunk-group`)
perm(0600)
);
};

# ===============================================================================================
# blocks for direct connection to Splunk via Kafka and HEC
# ===============================================================================================
# ===============================================================================================
# Kafka with Metadata (Facility and Priority):
# ===============================================================================================

block destination d_kafka_with_metadata (kafka-libs(`kafka-lib-dir`)
kafka-brokers(`splunk-kafka-brokers`)
sourcetype(`splunk-sourcetype`)
topic(`splunk-topic`)
index(`splunk-index`)
use_template(`splunk-default-template`)
) {
kafka(client-lib-dir("`kafka-libs`")
kafka-bootstrap-servers("`kafka-brokers`")
persist-name("`kafka_brokers`_`topic`_`sourcetype`_`index`")
template('$(format-json
time=$S_UNIXTIME.$S_MSEC
host=$HOST
source=${HOST_FROM}
sourcetype=`sourcetype`
index=`index`
event=$(template `use_template`)
fields.facility=$FACILITY
fields.severity=$LEVEL)')
topic("`topic`")
);
};

# ===============================================================================================
# Kafka with Full Metadata; additional fields can be added
# ===============================================================================================

block destination d_kafka_with_full_metadata (kafka-libs(`kafka-lib-dir`)
kafka-brokers(`splunk-kafka-brokers`)
sourcetype(`splunk-sourcetype`)
topic(`splunk-topic`)
index(`splunk-index`)
use_template(`splunk-default-template`)
) {
kafka(client-lib-dir("`kafka-libs`")
kafka-bootstrap-servers("`kafka-brokers`")
persist-name("`kafka_brokers`_`topic`_`sourcetype`_`index`")
template('$(format-json
time=$S_UNIXTIME.$S_MSEC
host=$HOST
source=${HOST_FROM}
sourcetype=`sourcetype`
index=`index`
event=$(template `use_template`)
fields.facility=$FACILITY
fields.severity=$LEVEL
fields.message_header=$MSGHDR
fields.program_name=$PROGRAM
fields.pid=$PID
fields.full_message=$(template t_everything)
)')
topic("`topic`")
);
};

# ===============================================================================================
# Basic Kafka (no indexed fields)
# ===============================================================================================

block destination d_kafka_basic (kafka-libs(`kafka-lib-dir`)
kafka-brokers(`splunk-kafka-brokers`)
sourcetype(`splunk-sourcetype`)
topic(`splunk-topic`)
index(`splunk-index`)
use_template(`splunk-default-template`)
) {
kafka(client-lib-dir("`kafka-libs`")
kafka-bootstrap-servers("`kafka-brokers`")
persist-name("`kafka_brokers`_`topic`_`sourcetype`_`index`")
template('$(format-json time=$S_UNIXTIME
host=$HOST
source=$HOST_FROM
sourcetype=`sourcetype`
index=`index`
event=$(template `use_template`))')
topic("`topic`")
);
};

# ===============================================================================================
# HEC with Metadata (Facility and Priority):
# Be sure to adjust batch paramaters below to suit scale/environment
# If validated certs are used, uncomment relevant lines in the tls() block below
# and change peer-verify() to "yes"
# ===============================================================================================

block destination d_hec_with_metadata (hec-url(`splunk-hec-url`)
hec-token(`splunk-hec-token`)
sourcetype(`splunk-sourcetype`)
index(`splunk-index`)
use_template(`splunk-default-template`)
) {
http(url("`hec-url`")
method("POST")
batch-lines(10)
batch-bytes(512Kb)
batch-timeout(5000)
user_agent("syslog-ng User Agent")
user("syslog-ng")
password("`hec-token`")
persist-name("`hec-url`_`sourcetype`_`hec-token`_`index`")
tls(peer-verify(no)
# ca-dir("dir")
# ca-file("ca")
# cert-file("cert")
# cipher-suite("cipher")
# key-file("key")
# peer-verify(yes|no)
# ssl-version(<the permitted SSL/TLS version>)
)
body('$(format-json
time=$S_UNIXTIME.$S_MSEC
host=$HOST
source=${HOST_FROM}
sourcetype=`sourcetype`
index=`index`
event=$(template `use_template`)
fields.facility=$FACILITY
fields.severity=$LEVEL)')
);
};

# ===============================================================================================
# HEC with Full Metadata; additional fields can be added
# Be sure to adjust batch paramaters below to suit scale/environment
# If validated certs are used, uncomment relevant lines in the tls() block below
# and change peer-verify() to "yes"
# ===============================================================================================

block destination d_hec_with_full_metadata(hec-url(`splunk-hec-url`)
hec-token(`splunk-hec-token`)
sourcetype(`splunk-sourcetype`)
index(`splunk-index`)
use_template(`splunk-default-template`)
) {
http(url("`hec-url`")
method("POST")
batch-lines(10)
batch-bytes(512Kb)
batch-timeout(5000)
user_agent("syslog-ng User Agent")
user("syslog-ng")
password("`hec-token`")
persist-name("`hec-url`_`sourcetype`_`hec-token`_`index`")
tls(peer-verify(no)
# ca-dir("dir")
# ca-file("ca")
# cert-file("cert")
# cipher-suite("cipher")
# key-file("key")
# peer-verify(yes|no)
# ssl-version(<the permitted SSL/TLS version>)
)
body('$(format-json
time=$S_UNIXTIME.$S_MSEC
host=$HOST
source=${HOST_FROM}
sourcetype=`sourcetype`
index=`index`
event=$(template `use_template`)
fields.fullhost_from=${FULLHOST_FROM}
fields.facility=$FACILITY
fields.severity=$LEVEL
fields.message_header=$MSGHDR
fields.program_name=$PROGRAM
fields.pid=$PID
fields.full_message=$(template t_everything)
)')
);
};

# ===============================================================================================
# Basic HEC (no indexed fields)
# ===============================================================================================

block destination d_hec_basic (hec-url(`splunk-hec-url`)
hec-token(`splunk-hec-token`)
sourcetype(`splunk-sourcetype`)
index(`splunk-index`)
use_template(`splunk-default-template`)
) {
http(url("`hec-url`")
method("POST")
batch-lines(10)
batch-bytes(512Kb)
batch-timeout(5000)
user_agent("syslog-ng User Agent")
user("syslog-ng")
password("`hec-token`")
persist-name("`hec-url`_`sourcetype`_`hec-token`_`index`")
tls(peer-verify(no)
# ca-dir("dir")
# ca-file("ca")
# cert-file("cert")
# cipher-suite("cipher")
# key-file("key")
# peer-verify(yes|no)
# ssl-version(<the permitted SSL/TLS version>)
)
body('$(format-json
time=$S_UNIXTIME.$S_MSEC
host=$HOST
source=${HOST_FROM}
sourcetype=`sourcetype`
index=`index`
event=$(template `use_template`))')
);
};
33 changes: 33 additions & 0 deletions package/etc/conf.d/b_parsers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ===============================================================================================
# ForcePoint (Websense)
# ===============================================================================================

# ===============================================================================================
# Log Format:
# <159>Dec 19 10:48:57 EST 10.203.28.21 vendor=Websense product=Security product_version=7.7.0 action=permitted severity=1 category=153 user=- src_host=10.64.134.74 src_port=62189 dst_host=mail.google.com dst_ip=74.125.224.53 dst_port=443 bytes_out=197 bytes_in=76 http_response=200 http_method=CONNECT http_content_type=- http_user_agent=Mozilla/5.0_(Windows;_U;_Windows_NT_6.1;_enUS;_rv:1.9.2.23)_Gecko/20110920_Firefox/3.6.23 http_proxy_status_code=200 reason=- disposition=1034 policy=- role=8 duration=0 url=https://mail.google.com
#
# Primary reason for non-compliance: %Z (timesone mnemonic) appended after date/time
# ===============================================================================================

block parser p_websense-parser(prefix(".websense.")) {
channel {
rewrite {
# normal BSD timestamp, plus a timezone code. Remove the
# timezone information for now.
subst('([A-Za-z]{3} [0-9 ]\d \d{2}:\d{2}:\d{2}) [A-Z]{3,4}' "$1 " flags(global) value("MSG"));

# add a $PROGRAM field, so that syslog-parser() would extract
# that properly
subst('(vendor=Websense)' "Websense: $1" flags(global) value("MSG"));
};
parser {
# by this time this message is a properly formatted syslog
# message
syslog-parser(time-zone(`default-timezone`));
# syslog-parser();

# extract name-value pairs.
# kv-parser(prefix("`prefix`"));
};
};
};
Loading

0 comments on commit 683bd9f

Please sign in to comment.