jq Snippets

Sample JSON File Sample JSON File containing well known programmers that we use for the following examples coders.json [ { "name": "Bjarne Stroustrup", "languages": [ { "name": "C++", "year_created": 1983 } ], "details": { "nationality": "Danish", "awards": ["IEEE Computer Society Computer Pioneer Award", "Charles Stark Draper Prize"] } }, { "name": "Guido van Rossum", "languages": [ { "name": "Python", "year_created": 1991 } ], "details": { "nationality": "Dutch", "awards": ["Free Software Foundation Award for the Advancement of Free Software", "NLUUG Award"] } }, { "name": "James Gosling", "languages": [ { "name": "Java", "year_created": 1995 } ], "details": { "nationality": "Canadian", "awards": ["Order of Canada", "The Economist Innovation Award"] } }, { "name": "Dennis Ritchie", "languages": [ { "name": "C", "year_created": 1972 }, { "name": "Unix", "year_created": 1969 } ], "details": { "nationality": "American", "awards": ["Turing Award", "National Medal of Technology"] } }, { "name": "Brendan Eich", "languages": [ { "name": "JavaScript", "year_created": 1995 } ], "details": { "nationality": "American", "awards": ["Webby Award"] } } ] ...

March 1, 2010 · 2 min · 223 words · Micha Kops

Kafka Snippets

Start an Image with kcat / kafka-cat for Debugging kubectl -n NAMESPACE run "$(whoami)-debug" -it --rm \ --image=confluentinc/cp-kafkacat:6.1.9 \ --restart=Never \ -- bash Dockerfile for Kafka Analysis Container with different Tools With jq, kafka console tools, schema registry tools and kafkacat installed …​. Dockerfile FROM confluentinc/cp-kafka:6.2.1 as cp-kafka FROM confluentinc/cp-schema-registry:6.2.1 as cp-schema-registry FROM debian:10-slim ARG DEBIAN_FRONTEND=noninteractive # Install necessary tools RUN apt-get update && apt-get install -y \ curl \ jq \ yq \ && rm -rf /var/lib/apt/lists/* # Install kafkacat binary RUN apt-get update && apt-get install -y kafkacat && rm -rf /var/lib/apt/lists/* # Copy Kafka binaries COPY --from=cp-kafka /usr/bin/kafka-* /usr/bin/ COPY --from=cp-schema-registry /usr/bin/schema-registry* /usr/bin/ # Copy entrypoint script COPY entrypoint.sh /usr/bin/entrypoint.sh RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["/usr/bin/entrypoint.sh"] ...

March 1, 2010 · 7 min · 1333 words · Micha Kops

Linux Snippets

These are not only linux snippets but also bash snippets and snippets using tools that run under Linux, *nix or sometimes even MacOSX, I should reorder this article someday ;) Settings for more reliable bash scripts set -euo pipefail this gives us …​ -e: exit script if a single command fails -u: exit script if an unset variable is used -o pipefail: return value of a pipeline is the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status ...

March 1, 2010 · 15 min · 3006 words · Micha Kops

Observability Snippets

Observability Strategies USE USE stands for: Utilization - Percent time the resource is busy, such as node CPU usage Saturation - Amount of work a resource has to do, often queue length or node load Errors - Count of error events This method is best for hardware resources in infrastructure, such as CPU, memory, and network devices. For more information, refer to The USE Method. Source: https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/best-practices/ RED RED stands for: Rate - Requests per second Errors - Number of requests that are failing Duration - Amount of time these requests take, distribution of latency measurements This method is most applicable to services, especially a microservices environment. For each of your services, instrument the code to expose these metrics for each component. RED dashboards are good for alerting and SLAs. A well-designed RED dashboard is a proxy for user experience. ...

March 1, 2010 · 2 min · 231 words · Micha Kops