Aller au contenu

Upgrade Loki#

Prerequisites#

FROM_LOKI_VERSION=xxx
TO_LOKI_VERSION=xxx

List of changes#

Several steps :

  • identify the main changes with the release-notes
  • read the full changelog
  • identify the upgrade impacts
  • identify configuration differences between both versions
    cd /tmp
    export CONFIG_FILE=local-config.yaml
    
    docker run --rm -t grafana/loki:${FROM_LOKI_VERSION} -config.file=/etc/loki/${CONFIG_FILE} -print-config-stderr 2>&1 | sed '/Starting Loki/q' > /tmp/loki_${FROM_LOKI_VERSION}
    docker run --rm -t grafana/loki:${TO_LOKI_VERSION} -config.file=/etc/loki/${CONFIG_FILE} -print-config-stderr 2>&1 | sed '/Starting Loki/q' > /tmp/loki_${TO_LOKI_VERSION}
    
    # Edit both files in /tmp and remove the first and last lines that are not configurations
    vim /tmp/loki_${FROM_LOKI_VERSION}
    vim /tmp/loki_${TO_LOKI_VERSION}
    
    cat /tmp/loki_${FROM_LOKI_VERSION} | yq -S . > /tmp/loki_${FROM_LOKI_VERSION}_sort
    cat /tmp/loki_${TO_LOKI_VERSION} | yq -S . > /tmp/loki_${TO_LOKI_VERSION}_sort
    
    diff --color=always --side-by-side /tmp/loki_${FROM_LOKI_VERSION}_sort /tmp/loki_${TO_LOKI_VERSION}_sort
    

Testing the configuration file with new version#

Prerequisites#

Retrieve the configuration file into a file

kubectl -n "${NAMESPACE}" get configmap loki -o jsonpath="{.data.config\.yaml}" > /tmp/loki.config.yaml

Test the configuration file#

cd /tmp
docker run --rm -t -v "$(pwd)":/config grafana/loki:${TO_LOKI_VERSION} -config.file=/config/loki.config.yaml -verify-config=true

Expected result :

level=info ... msg="config is valid"

Example of error :

failed parsing config: /config/loki.config.yaml: yaml: unmarshal errors:
  line 27: field shared_store not found in type compactor.Config