DirectorySecurity AdvisoriesPricing
/
Sign in
Directory
grafana-logcli logo

grafana-logcli

Last changed

Request a free trial

Contact our team to test out this image for free. Please also indicate any other images you would like to evaluate.

Tags
Overview
Comparison
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Container for grafana-logcli

Minimal image with logcli binary for querying and tailing logs from Grafana Loki.

Chainguard Containers are regularly-updated, secure-by-default container images.

Download this Container Image

For those with access, this container image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/grafana-logcli:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.

Compatibility Notes

Chainguard's grafana-logcli container image is comparable to the grafana/logcli image.

This image is aligned with the Loki version streams, ensuring compatibility with corresponding Loki server versions.

Setting Up Loki

Choose either Docker or Kubernetes deployment based on your environment:

Docker Deployment

For local testing or development, you can run Loki using Docker:

Step 1: Create a Loki configuration file

cat <<EOF > loki-config.yaml
auth_enabled: false

limits_config:
  allow_structured_metadata: true
  volume_enabled: true

server:
  http_listen_port: 3100

common:
  ring:
    instance_addr: 127.0.0.1
    kvstore:
      store: inmemory
  replication_factor: 1
  path_prefix: /tmp/loki

schema_config:
  configs:
  - from: 2020-05-15
    store: tsdb
    object_store: filesystem
    schema: v13
    index:
      prefix: index_
      period: 24h

storage_config:
  tsdb_shipper:
    active_index_directory: /tmp/loki/index
    cache_location: /tmp/loki/index_cache
  filesystem:
    directory: /tmp/loki/chunks

pattern_ingester:
  enabled: true

ingester:
  max_chunk_age: 5m
EOF

Step 2: Run Loki container

docker run -d \
  --name loki \
  -p 3100:3100 \
  -v $(pwd)/loki-config.yaml:/etc/loki/loki-config.yaml \
  cgr.dev/ORGANIZATION/loki:latest \
  -config.file=/etc/loki/local-config.yaml

Step 3: Verify Loki is running

curl http://localhost:3100/ready

You should receive a ready response.

Step 4: Push test logs to Loki

Send some test logs to verify Loki can receive and store data:

LOKI_URL="http://localhost:3100"
TIMESTAMP=$(printf '%s000000000' $(date +%s))
TEST_LOG="Test log from Docker deployment"

curl -X POST "${LOKI_URL}/loki/api/v1/push" \
  -H "Content-Type: application/json" \
  -H "X-Scope-OrgID: test" \
  -d "{
    \"streams\": [{
      \"stream\": {
        \"job\": \"test\",
        \"env\": \"docker-test\",
        \"test_id\": \"chainguard-test\"
      },
      \"values\": [[\"${TIMESTAMP}\", \"${TEST_LOG}\"]]
    }]
  }"
Kubernetes Deployment

For Kubernetes deployments, use the official Loki Helm chart:

Step 1: Add the Grafana Helm repository

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update

Step 2: Create a values file

cat <<EOF > loki-values.yaml
deploymentMode: SingleBinary

loki:
  image:
    registry: cgr.dev/ORGANIZATION
    repository: loki
    tag: latest

  auth_enabled: false
  commonConfig:
    ring:
      instance_addr: 127.0.0.1
      kvstore:
        store: inmemory
    replication_factor: 1
    path_prefix: "/tmp/loki"
  storage:
    type: filesystem
    bucketNames:
      chunks: loki-chunks
      ruler: loki-ruler
      admin: loki-admin
  schemaConfig:
    configs:
    - from: '2024-01-01'
      store: tsdb
      index:
        prefix: loki_index_
        period: 24h
      object_store: filesystem
      schema: v13
  storage_config:
    filesystem:
      directory: "/tmp/loki/chunks"

singleBinary:
  replicas: 1

read:
  replicas: 0

backend:
  replicas: 0

write:
  replicas: 0

chunksCache:
  enabled: false

resultsCache:
  enabled: false
EOF

Step 3: Install Loki

Using default configuration:

helm install loki grafana/loki --namespace default -f loki-values.yaml

Step 4: Verify the deployment

kubectl wait --for=condition=ready pod --selector=app.kubernetes.io/component=single-binary -n default --timeout=60s

Step 5: Push test logs to Loki

Send some test logs to verify Loki can receive and store data:

# Port-forward to access Loki from your local machine
kubectl port-forward svc/loki 3100:3100 &

# Push test logs
LOKI_URL="http://localhost:3100"
TIMESTAMP=$(printf '%s000000000' $(date +%s))
TEST_LOG="Test log from k8s deployment"

curl -X POST "${LOKI_URL}/loki/api/v1/push" \
  -H "Content-Type: application/json" \
  -H "X-Scope-OrgID: test" \
  -d "{
    \"streams\": [{
      \"stream\": {
        \"job\": \"test\",
        \"env\": \"k8s-test\",
        \"test_id\": \"chainguard-test\"
      },
      \"values\": [[\"${TIMESTAMP}\", \"${TEST_LOG}\"]]
    }]
  }"

Usage

Once you have Loki running, you can use LogCLI to query logs.

Basic Docker Usage

You can use LogCLI directly with Docker by passing the Loki server address via environment variables:

List available labels

docker run --rm \
  -e LOKI_ADDR=http://host.docker.internal:3100 \
  cgr.dev/ORGANIZATION/grafana-logcli:latest \
  labels

Querying a local Loki instance

docker run --rm \
  -e LOKI_ADDR=http://host.docker.internal:3100 \
  cgr.dev/ORGANIZATION/grafana-logcli:latest \
  query '{job="test"}'

Kubernetes Usage

List available labels

kubectl run logcli-labels \
  --image=cgr.dev/ORGANIZATION/grafana-logcli:latest \
  --restart=Never \
  --rm -it \
  --env="LOKI_ADDR=http://loki.default.svc.cluster.local:3100" \
  -- labels

Querying a local Loki instance

kubectl run logcli-query \
  --image=cgr.dev/ORGANIZATION/grafana-logcli:latest \
  --restart=Never \
  --rm -it \
  --env="LOKI_ADDR=http://loki.default.svc.cluster.local:3100" \
  -- query '{job="test"}'

Documentation and Resources

What are Chainguard Containers?

Chainguard's free tier of Starter container images are built with Wolfi, our minimal Linux undistro.

All other Chainguard Containers are built with Chainguard OS, Chainguard's minimal Linux operating system designed to produce container images that meet the requirements of a more secure software supply chain.

The main features of Chainguard Containers include:

For cases where you need container images with shells and package managers to build or debug, most Chainguard Containers come paired with a development, or -dev, variant.

In all other cases, including Chainguard Containers tagged as :latest or with a specific version number, the container images include only an open-source application and its runtime dependencies. These minimal container images typically do not contain a shell or package manager.

Although the -dev container image variants have similar security features as their more minimal versions, they include additional software that is typically not necessary in production environments. We recommend using multi-stage builds to copy artifacts from the -dev variant into a more minimal production image.

Need additional packages?

To improve security, Chainguard Containers include only essential dependencies. Need more packages? Chainguard customers can use Custom Assembly to add packages, either through the Console, chainctl, or API.

To use Custom Assembly in the Chainguard Console: navigate to the image you'd like to customize in your Organization's list of images, and click on the Customize image button at the top of the page.

Learn More

Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Librariescontact us for access.

Trademarks

This software listing is packaged by Chainguard. The trademarks set forth in this offering are owned by their respective companies, and use of them does not imply any affiliation, sponsorship, or endorsement by such companies.

Licenses

Chainguard's container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:

  • AGPL-3.0-or-later

  • GCC-exception-3.1

  • GPL-2.0-only

  • GPL-2.0-or-later

  • GPL-3.0-or-later

  • LGPL-2.1-or-later

  • MIT

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Compliance

Chainguard Containers are SLSA Level 3 compliant with detailed metadata and documentation about how it was built. We generate build provenance and a Software Bill of Materials (SBOM) for each release, with complete visibility into the software supply chain.

SLSA compliance at Chainguard

This image helps reduce time and effort in establishing PCI DSS 4.0 compliance with low-to-no CVEs.

PCI DSS at Chainguard

Category
Application

The trusted source for open source

Talk to an expert
© 2025 Chainguard. All Rights Reserved.
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsIntegrationsPricing