Hi,
I was looking for a way to send logs from github action runners to loki, running as part of our grafana enterprise installation.
I was able to do it using curl, but it would be much better to have an action defined which abstracts away all the detail.
Does anyone happen to know of, or has written an action?
I found an action called “loki-action” but it wasn’t what I wanted at all.
thanks for any thoughts.
FYI, this is the curl command needed
AWS_ACCOUNT=my-aws-account &&
AWS_REGION=us-east-1 &&
LOKI_URL="https://loki.example.com/loki/api/v1/push" &&
OS_PRETTY_NAME=$( awk -F= '/PRETTY_NAME=/{print $2}' )
RUNNER_IP=$( ip ad | grep -A 2 "^2" | awk '/inet/{print $2}' ) &&
tod_ymdhms=$( date +%Y%m%d-%H%M%S) &&
tod_nanos=$( date +%s)000000000 &&
curl -u "${LOKI_TENANT}:${LOKI_PASSWORD}" \
-i \
-H "Content-Type: application/json" \
-H "X-Scope-OrgID:$LOKI_TENANT" \
-XPOST \
-s "${LOKI_URL}" \
--data-raw "{\"streams\": [{ \"stream\": { \"aws_account\": \"$AWS_ACCOUNT\", \"Product\": \"$LOKI_TENANT\", \"log_level\":\"info\", \"region\": \"$AWS_REGION\", \"repo_name\":\"$GITHUB_REPOSITORY\", \"repo_owner\":\"$GITHUB_REPOSITORY_OWNER\", \"github_server_url\":\"$GITHUB_SERVER_URL\", \"runner_hostname\":\"$HOSTNAME\", \"runner_ip\":\"$RUNNER_IP\", \"runner_name\":\"$RUNNER_NAME\", \"runner_os\":\"$RUNNER_OS\", \"runner_os_name\":\"$OS_PRETTY_NAME\", \"runner_type\":\"self_docker\", \"target\":\"github-inventories\", \"workflow_name\":\"$GITHUB_WORKFLOW\", \"workflow_trigger\":\"$GITHUB_TRIGGERING_ACTOR\", \"ymdhms\":\"$tod_ymdhms\" }, \"values\": [ [ \"$tod_nanos\", \"$message\" ] ] }]}"