question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fine-grained logging configuration and consistency

See original GitHub issue

One of the most important considerations in running production services is logging. It’s common practice to aggregate Kubernetes container logs (either the entire container log from the host system or specific files via a sidecar container) for analysis and search with a tool like Splunk or ElasticSearch. Ambassador’s logging is currently pretty sad: only logs to stdout/stderr, different components have different log formats, and some processes log without a datestamp altogether. All of this makes it more difficult than it should be to index Ambassador logs.

Ambassador should add configuration options for logging:

  • Envoy access log format (#701) https://www.envoyproxy.io/docs/envoy/latest/configuration/access_log
  • Log format for Python components (hot-restarter, kubewatch, diagd) using logging module (#441) https://docs.python.org/3/library/logging.html
  • Prefix for all logs in entrypoint.sh (including date(1) formatting for timestamps)
  • Log destination for all components, should allow writing each component’s logs to separate files (at specified paths) in addition to stdout/stderr
  • Ideal: a new LoggingService manifest for configuring direct log forwarding to Splunk HEC/ElasticSearch/etc.

Ambassador’s default configuration should log everything with the same format (at very least with a consistent timestamp prefix, including time zone).

I’ve attempted to use the sidecar method with a Splunk forwarder container. I had to write my own Dockerfile that depends on Ambassador and adds a custom entrypoint to tee the logs into files:

Dockerfile

ARG VERSION
FROM quay.io/datawire/ambassador:${VERSION}

RUN apk --no-cache add bash

WORKDIR /ambassador
COPY my_entrypoint.sh .
RUN chmod 755 my_entrypoint.sh

ENTRYPOINT [ "./my_entrypoint.sh" ]

my_entrypoint.sh

#!/bin/bash

mkdir -p /logs

exec > >(tee -a /logs/ambassador_stdout.log)
exec 2> >(tee -a /logs/ambassador_stderr.log)

# variants with added timestamps, but this causes double timestamps on some logs???
# exec > >(awk '{ print strftime("%Y-%m-%d %H:%M:%S %z"), $0; fflush(); }' | tee -a /logs/ambassador_stdout.log)
# exec 2> >(awk '{ print strftime("%Y-%m-%d %H:%M:%S %z"), $0; fflush(); }' | tee -a /logs/ambassador_stderr.log)

exec ./entrypoint.sh

(Installing Bash is required to get >() process redirection)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
HT154commented, Nov 24, 2020

nooope

3reactions
stale[bot]commented, Aug 4, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fine-grained logging configuration and consistency · Issue #748
One of the most important considerations in running production services is logging. It's common practice to aggregate Kubernetes container ...
Read more >
Fine-grained logging - AWS IoT Device Management Workshop
Fine-grained logging allows you to specify a logging level for a target. A target is defined by a resource type and a resource...
Read more >
Fine-grained consistency for geo-replicated systems | USENIX
In this paper, we present a novel fine-grained consistency definition, Par- tial Order-Restrictions consistency (or short, PoR consis- tency), ...
Read more >
Configure fine-grained access control | Cloud Spanner
Configuring fine-grained access control involves the following steps: Create database roles and grant privileges. Optional: Create a hierarchy of roles with ...
Read more >
Flogger Best Practices - Google
When possible, log objects, not strings · Avoid doing work at log sites · Don't be afraid to add fine-grained logging to your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found