dev/sg: introduce 'sg ci logs' with Loki support
Created by: bobheadxi
Introduce sg ci logs
to pull job logs from a build's (by default) failed jobs for you to grep, pipe to another file, or do whatever manipulation you want with it. sg ci logs
also includes support for pushing logs into a Loki instance for aggregation and querying, for example:
sg run loki grafana # grafana and loki
sg ci logs --out=http://127.0.0.1:3100 # push job logs to a Loki instance
A long-term goal of the Loki support introduced here is to have failed builds automatically upload logs for query. This is part of work that closes #25562 (closed) - learn more about these efforts in RFC 496: https://github.com/sourcegraph/sourcegraph/issues/25768
Other usage examples:
sg ci logs # print to stdout
sg ci logs | grep blahblah # look for something in particular
sg ci logs --branch=main |> test.log # pipe last job failures logs from main into a file
The intended scope of this is to just be a simple log dump to stdout or local Loki. Automation within the pipeline run (if we decide to do it) will be a follow-up.