Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ services:
STAKER_SCRIPTS_VERSION: v0.1.1
restart: unless-stopped
environment:
SHUTTER_API_NODE_PRIVATEKEY: ""
SHUTTER_PUSH_METRICS_ENABLED: false
KEYPER_NAME: ""
ETHEREUM_WS: ""
- SHUTTER_API_NODE_PRIVATEKEY=""
- SHUTTER_PUSH_METRICS_ENABLED=false
- KEYPER_NAME=""
- ETHEREUM_WS=""
- SHUTTER_PUSH_LOGS_ENABLED=false
- PUSHGATEWAY_USERNAME=""
- PUSHGATEWAY_PASSWORD=""
volumes:
- chain:/chain
- keyper-config:/keyper/config
Expand Down
18 changes: 15 additions & 3 deletions setup-wizard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ fields:
service: shutter
required: true

- id: enable_push_logs
title: Enable Push Logs
description: |
Enable the push logs feature to send logs to an external server controlled by Shutter.
target:
type: environment
name: SHUTTER_PUSH_LOGS_ENABLED
service: [shutter, metrics]
enum:
- "true"
- "false"

- id: enable_push_metrics
title: Enable Push Metrics
description: |
Expand All @@ -46,7 +58,7 @@ fields:
- id: pushgateway_url
title: Pushgateway URL
description: |
The URL of the Pushgateway server to send metrics to.
The URL of the Pushgateway server to send metrics/logs to.
target:
type: environment
name: PUSHGATEWAY_URL
Expand All @@ -61,7 +73,7 @@ fields:
target:
type: environment
name: PUSHGATEWAY_USERNAME
service: metrics
service: [metrics, shutter]
required: false
if: { enable_push_metrics: { "enum": ["true"] } }

Expand All @@ -72,7 +84,7 @@ fields:
target:
type: environment
name: PUSHGATEWAY_PASSWORD
service: metrics
service: [metrics, shutter]
required: false
secret: true
if: { enable_push_metrics: { "enum": ["true"] } }
14 changes: 12 additions & 2 deletions shutter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG ASSETS_VERSION
ARG UPSTREAM_VERSION

FROM ghcr.io/shutter-network/assets:${ASSETS_VERSION} as assets
FROM ghcr.io/shutter-network/assets:${ASSETS_VERSION} AS assets

RUN rsync -aq --delete /assets-source/ /assets/

Expand Down Expand Up @@ -40,6 +40,7 @@ ADD ${STAKER_SCRIPTS_URL}/dvt_lsd_tools.sh /etc/profile.d/

COPY go-shutter-settings ${SHUTTER_SETTINGS_SRC_DIR}
COPY supervisord.conf /etc/supervisord.conf
COPY promtail_config.yaml /etc/promtail_config.yaml

RUN go build -C ${SHUTTER_SETTINGS_SRC_DIR} -o /usr/local/bin/go_shutter_settings

Expand All @@ -49,9 +50,18 @@ RUN mkdir -p ${KEYPER_CONFIG_DIR} ${SHUTTER_CHAIN_DIR} ${ASSETS_DIR} /opt/superv
COPY scripts /usr/local/bin/
COPY --from=assets ${ASSETS_DIR}/ ${ASSETS_DIR}/

# For pushing logs to loki
RUN apt-get -y install wget gpg
RUN mkdir -p /etc/apt/keyrings/
RUN wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee /etc/apt/sources.list.d/grafana.list
# promtail & rotatelogs (from apache2)
RUN apt-get update && apt-get -y install promtail apache2


# Placed here to rebuild less layers
ENV CHAIN_PORT=${CHAIN_PORT} \
SHUTTER_P2P_LISTENADDRESSES="/ip4/0.0.0.0/tcp/${KEYPER_PORT},/ip4/0.0.0.0/udp/${KEYPER_PORT}/quic-v1" \
NETWORK=${NETWORK}

ENTRYPOINT ["supervisord", "-c", "/etc/supervisord.conf"]
ENTRYPOINT ["supervisord", "-c", "/etc/supervisord.conf"]
46 changes: 46 additions & 0 deletions shutter/promtail_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
server:
http_listen_port: 9080
grpc_listen_port: 0

positions:
filename: /tmp/positions.yaml

client:
url: https://logs.metrics.shutter.network/insert/loki/api/v1/push
basic_auth:
username: ${PUSHGATEWAY_USERNAME}
password: ${PUSHGATEWAY_PASSWORD}

scrape_configs:
- job_name: configure
pipeline_stages:
- docker:
static_configs:
- targets:
- localhost
labels:
job: configure
host: ${KEYPER_NAME}
__path__: /tmp/configure.log

- job_name: keyper
pipeline_stages:
- docker:
static_configs:
- targets:
- localhost
labels:
job: keyper
host: ${KEYPER_NAME}
__path__: /tmp/keyper.log

- job_name: chain
pipeline_stages:
- docker:
static_configs:
- targets:
- localhost
labels:
job: chain
host: ${KEYPER_NAME}
__path__: /tmp/chain.log
8 changes: 6 additions & 2 deletions shutter/scripts/run_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
run_chain() {

echo "[INFO | chain] Starting chain..."

$SHUTTER_BIN chain --config "$SHUTTER_CHAIN_CONFIG_FILE"
if [[ SHUTTER_PUSH_LOGS_ENABLED=true ]];
then
$SHUTTER_BIN chain --config "$SHUTTER_CHAIN_CONFIG_FILE" |& rotatelogs -n 1 -e -c /tmp/chain.log 5M
Copy link

Choose a reason for hiding this comment

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

Does the "rotation" with only one file work correctly with promtail without causing log lines to be missed?

Reading the promtail logs on logrotation suggests it might not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw that documentation, but I could not fully figure out, whether it applies in this case. My assessment was that using a single file would actually work as intended, but now that I re-read your link I am not sure anymore.

Do you have another suggestion how to achieve what we need?:

  • redirect output to file AND stdout (to keep docker logging working)
  • keep the logfile from growing indefinitely

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a comment but decided to leave it like this.

else
$SHUTTER_BIN chain --config "$SHUTTER_CHAIN_CONFIG_FILE"
fi
}

run_chain
9 changes: 9 additions & 0 deletions shutter/scripts/run_configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash


if [[ SHUTTER_PUSH_LOGS_ENABLED=true ]];
then
configure.sh |& rotatelogs -n 1 -e -c /tmp/configure.log 5M
else
configure.sh
fi
7 changes: 6 additions & 1 deletion shutter/scripts/run_keyper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ perform_chain_healthcheck() {
}

run_keyper() {
$SHUTTER_BIN shutterservicekeyper --config "$KEYPER_CONFIG_FILE"
if [[ SHUTTER_PUSH_LOGS_ENABLED=true ]];
then
$SHUTTER_BIN shutterservicekeyper --config "$KEYPER_CONFIG_FILE" |& rotatelogs -n 1 -e -c /tmp/keyper.log 5M
else
$SHUTTER_BIN shutterservicekeyper --config "$KEYPER_CONFIG_FILE"
fi
}

perform_chain_healthcheck
Expand Down
12 changes: 12 additions & 0 deletions shutter/scripts/run_promtail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

run_promtail() {
if [[ $SHUTTER_PUSH_LOGS_ENABLED=true ]];
then
promtail -config.expand-env=true -log-config-reverse-order -print-config-stderr -config.file /etc/promtail_config.yaml
else
tail -f /dev/null
fi
}

run_promtail
16 changes: 14 additions & 2 deletions shutter/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
serverurl=unix:///var/run/supervisor.sock

[program:configure]
command = configure.sh
command = run_configure.sh
priority = 1
autostart = true
autorestart = false
Expand Down Expand Up @@ -47,4 +47,16 @@ autorestart = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
stderr_logfile_maxbytes = 0

[program:promtail]
command = run_promtail.sh ; we ingest 'rotatelogs' managed logfiles -- there is potential for some missed log lines.
priority = 4
autostart = %(ENV_SHUTTER_PUSH_LOGS_ENABLED)s
startretries = 9999 ; A large number enough to cover node updates
autorestart = %(ENV_SHUTTER_PUSH_LOGS_ENABLED)s
environment = KEYPER_NAME="%(ENV_KEYPER_NAME)s",PUSHGATEWAY_USERNAME="%(ENV_PUSHGATEWAY_USERNAME)s",PUSHGATEWAY_PASSWORD="%(ENV_PUSHGATEWAY_PASSWORD)s",SHUTTER_PUSH_LOGS_ENABLED="%(ENV_SHUTTER_PUSH_LOGS_ENABLED)s"
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
Loading