-
Notifications
You must be signed in to change notification settings - Fork 97
Push agent v2 logs to QE grafana #1185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6d4fe19
Push agent v2 logs to QE grafana
john-david3 7e969e8
fix ci env var
john-david3 8c89e17
Update env vars
john-david3 ee36009
use bash for pipestatus
john-david3 b04704e
remove comment
john-david3 5be6f39
add temp status check
john-david3 47e2b87
add logs
john-david3 0f82539
add mkdir for sub-directories
john-david3 8d2e214
update integration tests
john-david3 a6ad44e
fix filepaths
john-david3 88acdeb
add mkdir step
john-david3 e6ef341
fix regex and move promtail setup
john-david3 8bfc141
cleanup
john-david3 6d9dbbe
Add mkdir to script
john-david3 85058aa
fix typo
john-david3 142b3fe
Move promtail setup
john-david3 f2da76f
prune container before starting promtail
john-david3 0cb9554
move cleanup
john-david3 891038c
update promtail
john-david3 ab1bac2
fix typo
john-david3 729e6a1
update promtail
john-david3 eb66f07
comment promtail
john-david3 f612e57
change build dir
john-david3 6530e28
Add OSS tests
john-david3 70f1326
change dockerfile build
john-david3 e4c3cba
debug
john-david3 5388dc6
update path
john-david3 95d71f9
debug
john-david3 56a495f
fix filename
john-david3 7664bf8
Move promtail
john-david3 4490805
pass secret to config
john-david3 a95e948
fix secret
john-david3 1fd361b
add unit tests
john-david3 9bc5c54
Remove whole job logs
john-david3 1f5e099
PR feedback
john-david3 b8a7e7e
Reorder copys
john-david3 467b83e
change build
john-david3 bffe322
fix typo
john-david3 eee80d9
PR feedback
john-david3 378e371
Merge branch 'dev-v2' into v2-qe-dashboard
john-david3 4d0e1dc
merge dev-v2
john-david3 414fa54
remove hardcoded public key from dockerfile
john-david3 2c05bd1
fix tests
john-david3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Start Promtail | ||
description: Start promtail in a Docker container to send test results to loki | ||
inputs: | ||
loki-dashboard-url: | ||
description: "URL of the Loki dashboard to send the logs" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Start Promtail container | ||
shell: bash | ||
run: | | ||
docker run -d \ | ||
--name=promtail \ | ||
-v "${{ github.workspace }}/test/dashboard/prep/promtail.yaml:/etc/promtail/config.yaml" \ | ||
-v "${{ github.workspace }}/test/dashboard/logs:/var/log" \ | ||
-e TEST_OUTDIR=test/dashboard/logs \ | ||
-e GITHUB_RUN_ID=${{ github.run_id }} \ | ||
-e GITHUB_JOB=${{ github.job }} \ | ||
-e GITHUB_WORKFLOW=${{ github.workflow }} \ | ||
-e GITHUB_EVENT_NAME=${{ github.event_name }} \ | ||
-e GITHUB_SERVER_URL=${{ github.server_url }} \ | ||
-e GITHUB_REPOSITORY=${{ github.repository }} \ | ||
-e GITHUB_HEAD_REF=${{ github.head_ref }} \ | ||
-e GITHUB_SHA=${{ github.sha }} \ | ||
-e GITHUB_ACTOR=${{ github.actor }} \ | ||
-e LOKI_DASHBOARD_URL=${{ inputs.loki-dashboard-url }} \ | ||
grafana/promtail:3.4.4 \ | ||
-config.file=/etc/promtail/config.yaml \ | ||
-config.expand-env=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,98 @@ | ||||||||||||||
#!/bin/bash | ||||||||||||||
|
||||||||||||||
JOB_RESULT="$1" | ||||||||||||||
START_TIME="$2" | ||||||||||||||
TEST_TYPE="$3" | ||||||||||||||
WORKSPACE="$4" | ||||||||||||||
|
||||||||||||||
INPUT_FILE="$WORKSPACE/test/dashboard/logs/$TEST_TYPE/raw_logs.log" | ||||||||||||||
OUTPUT_PATH="$WORKSPACE/test/dashboard/logs/$TEST_TYPE" | ||||||||||||||
|
||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
END_TIME="`date "+%Y-%m-%dT%H:%M:%S.%NZ"`" | ||||||||||||||
START_SECONDS=$(date -d "$START_TIME" +%s.%N) | ||||||||||||||
END_SECONDS=$(date -d "$END_TIME" +%s.%N) | ||||||||||||||
DURATION=$(echo "$END_SECONDS - $START_SECONDS" | bc) | ||||||||||||||
|
||||||||||||||
MSG="" # individual test msg | ||||||||||||||
FAIL_MSG="" # msg for entire job run | ||||||||||||||
RESULT="" | ||||||||||||||
HAS_FAILED=false | ||||||||||||||
IS_RUNNING=false | ||||||||||||||
|
||||||||||||||
load_job_status(){ | ||||||||||||||
if [ "$JOB_RESULT" == "success" ]; then | ||||||||||||||
RESULT="pass" | ||||||||||||||
elif [ "$JOB_RESULT" == "failure" ]; then | ||||||||||||||
RESULT="fail" | ||||||||||||||
else | ||||||||||||||
RESULT="skip" | ||||||||||||||
fi | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
format_logs_to_json(){ | ||||||||||||||
line="$1" | ||||||||||||||
json="{" | ||||||||||||||
|
||||||||||||||
while [[ "$line" =~ ([a-zA-Z0-9_]+)=((\"([^\"\\]|\\.)*\")|[^[:space:]]+) ]]; do | ||||||||||||||
key="${BASH_REMATCH[1]}" | ||||||||||||||
value="${BASH_REMATCH[2]}" | ||||||||||||||
line="${line#*"${key}=${value}"}" | ||||||||||||||
|
||||||||||||||
if [[ "$value" == \"*\" ]]; then | ||||||||||||||
value="${value:1:${#value}-2}" | ||||||||||||||
value="${value//\"/\\\"}" | ||||||||||||||
fi | ||||||||||||||
json+="\"$key\":\"$value\"," | ||||||||||||||
done | ||||||||||||||
|
||||||||||||||
json="${json%,}}" | ||||||||||||||
echo "$json" | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
format_results(){ | ||||||||||||||
while IFS= read -r line; do | ||||||||||||||
|
||||||||||||||
if [[ "$line" =~ ^===\ RUN[[:space:]]+(.+) ]]; then | ||||||||||||||
TEST_NAME="${BASH_REMATCH[1]}" | ||||||||||||||
IS_RUNNING=true | ||||||||||||||
MSG="" | ||||||||||||||
TEST_START="" | ||||||||||||||
TEST_END="" | ||||||||||||||
mkdir -p "$OUTPUT_PATH/$TEST_NAME/" | ||||||||||||||
RESULT_FILE="$OUTPUT_PATH/$TEST_NAME/result.json" | ||||||||||||||
LOG_FILE="$OUTPUT_PATH/$TEST_NAME/test.log" | ||||||||||||||
elif [[ "$line" =~ ([0-9T:\.\-Z]+)[[:space:]]+testing ]]; then | ||||||||||||||
TEST_START="${BASH_REMATCH[1]}" | ||||||||||||||
elif [[ "$line" =~ ([0-9T:\.\-Z]+)[[:space:]]+finished[[:space:]]testing ]]; then | ||||||||||||||
TEST_END="${BASH_REMATCH[1]}" | ||||||||||||||
elif [[ "$line" == "FAIL" ]]; then | ||||||||||||||
HAS_FAILED=false | ||||||||||||||
MSG="$MSG_STR" | ||||||||||||||
FAIL_MSG+="$MSG" | ||||||||||||||
HAS_FAILED=false | ||||||||||||||
echo "{\"start_at\": \"$START_TIME\", \"end_at\": \"$END_TIME\", \"duration_seconds\": \"$DURATION\", \"result\": \"$TEST_RES\", \"msg\": \"$MSG\"}" > $RESULT_FILE | ||||||||||||||
elif [[ "$line" == "--- PASS"* ]]; then | ||||||||||||||
TEST_RES="pass" | ||||||||||||||
IS_RUNNING=false | ||||||||||||||
echo "{\"start_at\": \"$START_TIME\", \"end_at\": \"$END_TIME\", \"duration_seconds\": \"$DURATION\", \"result\": \"$TEST_RES\", \"msg\": \"$MSG\"}" > $RESULT_FILE | ||||||||||||||
elif [[ "$line" == "--- FAIL"* ]]; then | ||||||||||||||
TEST_RES="fail" | ||||||||||||||
HAS_FAILED=true | ||||||||||||||
IS_RUNNING=false | ||||||||||||||
elif [[ "$line" == time=* && "$line" == *level=* ]]; then | ||||||||||||||
LOG_LINE=$(format_logs_to_json "$line") | ||||||||||||||
echo "$LOG_LINE" >> "$LOG_FILE" | ||||||||||||||
fi | ||||||||||||||
|
||||||||||||||
if [ $HAS_FAILED == true ]; then | ||||||||||||||
MSG_STR+="$line" | ||||||||||||||
fi | ||||||||||||||
|
||||||||||||||
done < "$INPUT_FILE" | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
# Main body of the script | ||||||||||||||
{ | ||||||||||||||
load_job_status | ||||||||||||||
format_results | ||||||||||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
server: | ||
http_listen_port: 9080 | ||
grpc_listen_port: 0 | ||
log_level: info | ||
|
||
positions: | ||
filename: /tmp/positions.yaml | ||
sync_period: "10s" | ||
|
||
clients: | ||
- url: "${LOKI_DASHBOARD_URL}" | ||
external_labels: | ||
systest_project: agent_v2 | ||
systest_type: "${GITHUB_JOB}" | ||
timeout: 30s | ||
backoff_config: | ||
min_period: 500ms | ||
max_period: 5s | ||
max_retries: 5 | ||
|
||
scrape_configs: | ||
- job_name: test-results | ||
static_configs: | ||
- targets: | ||
- localhost | ||
labels: | ||
systest_job: test-results | ||
__path__: /var/log/**/result.json | ||
pipeline_stages: | ||
- json: | ||
expressions: | ||
time: | ||
- timestamp: | ||
source: time | ||
format: RFC3339Nano | ||
- template: | ||
source: ci_pipeline_id | ||
template: "${GITHUB_RUN_ID}" | ||
- template: | ||
source: ci_pipeline_url | ||
template: "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | ||
- template: | ||
source: ci_pipeline_name | ||
template: "${WORKFLOW}" | ||
- template: | ||
source: ci_pipeline_source | ||
template: "${GITHUB_EVENT_NAME}" | ||
- template: | ||
source: ci_job_name | ||
template: "${GITHUB_JOB}" | ||
- template: | ||
source: ci_commit_ref | ||
template: "${GITHUB_HEAD_REF}" | ||
- template: | ||
source: ci_commit_sha | ||
template: "${GITHUB_SHA}" | ||
- template: | ||
source: ci_commit_author | ||
template: "${GITHUB_ACTOR}" | ||
- template: | ||
source: systest_path | ||
template: '{{ trimPrefix "${TEST_OUTDIR}/" .filename | dir | replace "." "/" }}' | ||
|
||
- structured_metadata: | ||
ci_pipeline_id: | ||
ci_pipeline_url: | ||
ci_pipeline_name: | ||
ci_pipeline_source: | ||
ci_job_name: | ||
ci_commit_ref: | ||
ci_commit_sha: | ||
ci_commit_author: | ||
filename: | ||
systest_path: | ||
|
||
- labeldrop: | ||
- filename | ||
|
||
- job_name: test-logs | ||
static_configs: | ||
- targets: | ||
- localhost | ||
labels: | ||
systest_job: test-logs | ||
__path__: /var/log/**/test.log | ||
pipeline_stages: | ||
- json: | ||
expressions: | ||
time: | ||
- timestamp: | ||
source: time | ||
format: RFC3339Nano | ||
- template: | ||
source: ci_pipeline_id | ||
template: "${GITHUB_RUN_ID}" | ||
- template: | ||
source: ci_pipeline_url | ||
template: "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | ||
- template: | ||
source: ci_pipeline_name | ||
template: "${WORKFLOW}" | ||
- template: | ||
source: ci_pipeline_source | ||
template: "${GITHUB_EVENT_NAME}" | ||
- template: | ||
source: ci_job_name | ||
template: "${GITHUB_JOB}" | ||
- template: | ||
source: ci_commit_ref | ||
template: "${GITHUB_HEAD_REF}" | ||
- template: | ||
source: ci_commit_sha | ||
template: "${GITHUB_SHA}" | ||
- template: | ||
source: ci_commit_author | ||
template: "${GITHUB_ACTOR}" | ||
- template: | ||
source: systest_path | ||
template: '{{ trimPrefix "${TEST_OUTDIR}/" .filename | dir | replace "." "/" }}' | ||
|
||
- structured_metadata: | ||
ci_pipeline_id: | ||
ci_pipeline_url: | ||
ci_pipeline_name: | ||
ci_pipeline_source: | ||
ci_job_name: | ||
ci_commit_ref: | ||
ci_commit_sha: | ||
ci_commit_author: | ||
filename: | ||
systest_path: | ||
|
||
- labeldrop: | ||
- filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ ARG CONTAINER_OS_TYPE | |
|
||
WORKDIR /agent | ||
COPY ./build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE} /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE} | ||
COPY ./ /agent | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed ? |
||
RUN apk add --allow-untrusted /agent/build/${PACKAGE_NAME}.${CONTAINER_OS_TYPE} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.