@@ -194,58 +194,17 @@ jobs:
194194 deleteJobType : ${{ matrix.pool.deleteJobType }}
195195 isCiPool : ${{ matrix.pool.isCiPool }}
196196
197- - name : " Create Pool, push metrics "
197+ - name : " Create Pool"
198198 run : |
199- export SFPOWERSCRIPTS_STATSD=true
200- echo "statsd: $SFPOWERSCRIPTS_STATSD"
201- bash -c 'echo "statsd: $SFPOWERSCRIPTS_STATSD"'
202199 sfp pool prepare --poolconfig "${{ matrix.pool.poolConfigPath }}" --targetdevhubusername devhub
203- if [[ -f .sfpowerscripts/logs/metrics.log ]]; then
204- # send some stats whilst we're at it
205- echo Metrics file found.
206- nl .sfpowerscripts/logs/metrics.log
207- metrics=$(jq --slurp --raw-output '
208- [
209- .[] | select(.value != null)
210- ] |
211- # just keep the last value
212- reverse | unique_by(.metric, .tags) |
213- group_by(.type)[][] |
214- (
215- if .type == "count" then "counter"
216- # note the spelling
217- elif .type == "guage" then "gauge"
218- # statsd-timers are always in ms. prometheus has no such type, so just
219- # use a gauge
220- elif .type == "timers" then "gauge"
221- # anything else, handle it when the time comes
222- else "unknown" end) as $type |
223- # only allow alpha and _ in metrics name
224- (.metric | gsub("[^a-z]"; "_")) as $metric |
225- # transform tags into prometheus
226- (.tags // {} | to_entries | map(.key + "=\"" + .value + "\"") | join(",")) as $tags |
227- # put it all together. one line with description, one line with metric.
228- "# TYPE \($metric) \($type)\n\($metric){\($tags)} \(.value)"
229- ' .sfpowerscripts/logs/metrics.log | awk '/^# TYPE / && a[$3]++ {next}; 1')
230- echo "METRICSKEY len: ${#METRICSKEY}"
231- keyfile=$(mktemp) || exit 1
232- cat > "$keyfile" <<< "$METRICSKEY"
233- sig=$(printf %s "$metrics" | openssl dgst -sha256 -sign "$keyfile" -out - | base64 -w0)
234- jq --compact-output --null-input \
235- --arg metrics "$metrics" \
236- --arg runner sf-platform \
237- --arg sig "$sig" \
238- '{"runner":$runner,"metrics":$metrics,"signature":$sig}' |
239- tee >(curl -D- -H 'Content-Type: application/json' --data-binary @- \
240- https://sf-github-metrics.ekstern.dev.nav.no/measures/job/sfplatform)
241- else
242- echo No metrics file this time.
243- ls -laR .sfpowerscripts
244- fi
245200 env :
246- METRICSKEY : ${{ secrets.METRICS_KEYS }}
247201 NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
248202
203+ - name : Push logged metrics
204+ uses : navikt/sf-platform/.github/actions/pushLoggedMetrics@main
205+ with :
206+ metricsKey : ${{ secrets.METRICS_KEYS }}
207+
249208 - name : " Delete orphans"
250209 uses : navikt/sf-gha-deleteScratchPool@1f0986d2312a2969e658946acb496f6dcd7d4032
251210 with :
0 commit comments