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

Visualize NAP logs in mock collector grafana #939

Open
wants to merge 28 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c5deb61
feat: add syslog receiver
RRashmit Nov 13, 2024
0162757
chore: update port to non priviledged
RRashmit Nov 13, 2024
036aba9
chore: update the syslog type and template
RRashmit Nov 18, 2024
0e138e7
chore: update comments
RRashmit Nov 18, 2024
4f6db4a
chore: update the docker
RRashmit Nov 18, 2024
409242c
chore: updated the otel collector pipeline
RRashmit Nov 25, 2024
3fde54c
chore: update multiple syslog servers
RRashmit Nov 25, 2024
45bb8ee
Merge branch 'v3' into poc-v3-otel-syslog
dhurley Nov 27, 2024
7ddc9b8
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
1b7a359
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
6f0edde
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
5faae62
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
bbc3eb5
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
29e07a0
Merge branch 'v3' into poc-v3-otel-syslog
dhurley Dec 2, 2024
f3b0636
Visualize NAP logs in mock collector grafana
dhurley Dec 2, 2024
2597fd6
Visualize NAP logs in mock collector grafana
dhurley Dec 2, 2024
079d594
Visualize NAP logs in mock collector grafana
dhurley Dec 3, 2024
ddb02df
Remove key_value_parser operator
dhurley Dec 3, 2024
4f9f42a
Merge branch 'poc-v3-otel-syslog' into chore/add-nap-to-mock-collector
dhurley Dec 3, 2024
5d0f9b0
Update tcplog timestamp operator
dhurley Dec 4, 2024
653c907
Merge branch 'poc-v3-otel-syslog' into chore/add-nap-to-mock-collector
dhurley Dec 4, 2024
a65e3d3
Update NGINX plus dockerfile to always build with platform set to amd…
dhurley Dec 17, 2024
771a1cf
Update how long to wait for nginx master process to start in dockerfile
dhurley Dec 20, 2024
dc26a5d
Merge branch 'v3' into chore/add-nap-to-mock-collector
dhurley Dec 20, 2024
b8bd1b3
Fix OSARCH variable in Makefile
dhurley Dec 20, 2024
1593c26
Fix OSARCH variable in Makefile
dhurley Dec 20, 2024
29f338e
Update README
dhurley Jan 7, 2025
4413e5e
Fix makefile target
dhurley Jan 9, 2025
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
Prev Previous commit
Next Next commit
Visualize NAP logs in mock collector grafana
  • Loading branch information
dhurley committed Dec 2, 2024
commit f3b063685f27ca6b906b1539f745306c0a8b161c
3 changes: 2 additions & 1 deletion test/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ trap 'handle_term' TERM

# Launch nginx
echo "starting nginx ..."
/bin/su -s /bin/sh -c "/usr/share/ts/bin/bd-socket-plugin tmm_count 4 proc_cpuinfo_cpu_mhz 2000000 total_xml_memory 307200000 total_umu_max_size 3129344 sys_max_account_id 1024 no_static_config 2>&1 >> /var/log/app_protect/bd-socket-plugin.log &" nginx
/usr/sbin/nginx -g "daemon off;" &

nginx_pid=$!

SECONDS=0

while ! ps -ef | grep "nginx: master process" | grep -v grep; do
if (( SECONDS > 5 )); then
if (( SECONDS > 15 )); then
echo "couldn't find nginx master process"
exit 1
fi
Expand Down
14 changes: 10 additions & 4 deletions test/docker/nginx-plus/deb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ RUN --mount=type=secret,id=nginx-crt,dst=nginx-repo.crt \
# Create nginx user/group first, to be consistent throughout Docker variants
&& groupadd --system --gid 101 nginx \
&& useradd --system --gid nginx --no-create-home --home-dir /nonexistent --uid 101 nginx \
&& apt-get update \
&& apt-get update --allow-releaseinfo-change \
&& apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
gnupg1 \
lsb-release \
apt-transport-https \
git \
wget \
make \
gnupg2 \
ubuntu-keyring \
&& wget -qO - https://cs.nginx.com/static/keys/app-protect-security-updates.key | gpg --dearmor | tee /usr/share/keyrings/app-protect-security-updates.gpg >/dev/null \
&& wget -qO - https://cs.nginx.com/static/keys/nginx_signing.key | gpg --dearmor | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null \
&& \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
found=''; \
Expand All @@ -43,13 +48,15 @@ RUN --mount=type=secret,id=nginx-crt,dst=nginx-repo.crt \
# Uncomment individual modules if necessary
# Use versioned packages over defaults to specify a release
&& nginxPackages=" \
nginx-plus \
oliveromahony marked this conversation as resolved.
Show resolved Hide resolved
app-protect \
" \
&& echo "Acquire::https::pkgs.nginx.com::Verify-Peer \"true\";" > /etc/apt/apt.conf.d/90nginx \
&& echo "Acquire::https::pkgs.nginx.com::Verify-Host \"true\";" >> /etc/apt/apt.conf.d/90nginx \
&& echo "Acquire::https::pkgs.nginx.com::SslCert \"/etc/ssl/nginx/nginx-repo.crt\";" >> /etc/apt/apt.conf.d/90nginx \
&& echo "Acquire::https::pkgs.nginx.com::SslKey \"/etc/ssl/nginx/nginx-repo.key\";" >> /etc/apt/apt.conf.d/90nginx \
&& printf "deb https://pkgs.nginx.com/plus/${PLUS_VERSION}/ubuntu/ `lsb_release -cs` nginx-plus\n" > /etc/apt/sources.list.d/nginx-plus.list \
&& printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/app-protect/${PLUS_VERSION}/ubuntu `lsb_release -cs` nginx-plus\n" | tee /etc/apt/sources.list.d/nginx-app-protect.list \
&& printf "deb [signed-by=/usr/share/keyrings/app-protect-security-updates.gpg] https://pkgs.nginx.com/app-protect-security-updates/ubuntu `lsb_release -cs` nginx-plus\n" | tee -a /etc/apt/sources.list.d/nginx-app-protect.list \
&& mkdir -p /etc/ssl/nginx \
&& cat nginx-repo.crt > /etc/ssl/nginx/nginx-repo.crt \
&& cat nginx-repo.key > /etc/ssl/nginx/nginx-repo.key \
Expand All @@ -59,9 +66,8 @@ RUN --mount=type=secret,id=nginx-crt,dst=nginx-repo.crt \
curl \
gettext-base \
jq \
gnupg2 \
&& apt-get remove --purge -y lsb-release \
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx-plus.list \
&& apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx-plus.list /etc/apt/sources.list.d/nginx-app-protect.list \
&& rm -rf /etc/apt/apt.conf.d/90nginx /etc/ssl/nginx

EXPOSE 80
Expand Down
16 changes: 15 additions & 1 deletion test/mock/collector/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ services:
container_name: mock-collector-agent-with-nginx-plus
volumes:
- ./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf
- ./nginx-plus:/etc/nginx/
- ./nginx-plus/nginx.conf:/etc/nginx/nginx.conf
- ./nginx-plus/conf.d/default.conf:/etc/nginx/conf.d/default.conf
networks:
- metrics

Expand Down Expand Up @@ -59,6 +60,19 @@ services:
- grafana-storage:/var/lib/grafana
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
- ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
- ./grafana/provisioning/plugins:/etc/grafana/provisioning/plugins
- ./grafana/provisioning/dashboards:/var/lib/grafana/dashboards
networks:
- metrics

loki:
image: grafana/loki:latest
container_name: mock-collector-loki
restart: unless-stopped
ports:
- "3100:3100"
volumes:
- ./loki-config.yaml:/etc/loki/local-config.yaml
command: -config.file=/etc/loki/local-config.yaml
networks:
- metrics
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ datasources:
access: proxy
url: http://prometheus:9090
isDefault: true
- name: Loki
type: loki
uid: otel-loki-scraper
access: proxy
url: http://loki:3100
4 changes: 4 additions & 0 deletions test/mock/collector/mock-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ import (

"github.com/nginx/agent/v3/test/mock/collector/mock-collector/auth"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor"
"go.opentelemetry.io/collector/connector"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/debugexporter"
"go.opentelemetry.io/collector/exporter/otlpexporter"
"go.opentelemetry.io/collector/exporter/otlphttpexporter"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/batchprocessor"
Expand Down Expand Up @@ -85,13 +87,15 @@ func components() (otelcol.Factories, error) {
debugexporter.NewFactory(),
otlpexporter.NewFactory(),
prometheusexporter.NewFactory(),
otlphttpexporter.NewFactory(),
)
if err != nil {
return otelcol.Factories{}, err
}

factories.Processors, err = processor.MakeFactoryMap(
batchprocessor.NewFactory(),
resourceprocessor.NewFactory(),
)
if err != nil {
return otelcol.Factories{}, err
Expand Down
21 changes: 20 additions & 1 deletion test/mock/collector/nginx-plus/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
user nginx;
worker_processes auto;


load_module modules/ngx_http_app_protect_module.so;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

Expand Down Expand Up @@ -80,6 +82,23 @@ http {
status_zone my_location_zone2;
}
}

server {
listen 8099;
server_name localhost;
proxy_http_version 1.1;

app_protect_enable on;
app_protect_policy_file "/etc/app_protect/conf/NginxDefaultPolicy.json";
app_protect_security_log_enable on;
app_protect_security_log "/etc/app_protect/conf/log_default.json" syslog:server=127.0.0.1:5141;

location / {
client_max_body_size 0;
default_type text/html;
proxy_pass http://172.29.38.211/;
}
}

include /etc/nginx/conf.d/*.conf;
}
Expand Down
11 changes: 9 additions & 2 deletions test/mock/collector/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ exporters:
verbosity: detailed
sampling_initial: 5
sampling_thereafter: 200
otlphttp:
endpoint: http://loki:3100/otlp

processors:
batch:
resource:
Copy link

@sean-breen sean-breen Jan 8, 2025

Choose a reason for hiding this comment

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

At the moment it looks like this will be overwritten by the other resource attributes if defined here in the file.

attributes:
- key: service.name
value: "nginx.app.protect"
action: insert

extensions:
headers_check:
Expand All @@ -34,5 +41,5 @@ service:
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [batch]
exporters: [debug]
processors: [resource, batch]
exporters: [otlphttp]