Skip to content

Commit

Permalink
Merge pull request #2842 from ministryofjustice/chore/improve-seed-jo…
Browse files Browse the repository at this point in the history
…b-log-instructions

Improve seed job log checking instructions
  • Loading branch information
davidatkinsuk authored Jan 23, 2025
2 parents 2fb2851 + 39625a3 commit 01e5f54
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doc/how-to/run_seed_job_remotely.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ For XLSX files:
/app/run_seed_from_excel_job cas1_import_site_survey_rooms ap_seed_file
```

- Check the logs using [Azure Application Insights](https://dsdmoj.atlassian.net/wiki/spaces/AP/pages/4154196024/Viewing+and+Tailing+Kubernetes+logs) to see how processing is progressing. The following query will provide seed traces and exceptions only:
- Whilst App Insights can be used to view seed logs, we've found that if we're running multiple seed jobs concurrently, some logs are lost in app insights. Checking the container logs directly avoids this issue, although they're not retained for as long. E.g.

```./pod_logs preprod {container_name} | grep -i 'seed'```

- Alternatively, you can check the logs using [Azure Application Insights](https://dsdmoj.atlassian.net/wiki/spaces/AP/pages/4154196024/Viewing+and+Tailing+Kubernetes+logs) with the following query:
```
union traces, exceptions
| where cloud_RoleName == 'approved-premises-api' and customDimensions contains ("uk.gov.justice.digital.hmpps.approvedpremisesapi.seed")
Expand Down
23 changes: 23 additions & 0 deletions script/pod_logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

if [ -z "$1" ] || ! [[ "$1" =~ ^(dev|test|preprod|prod)$ ]]; then
echo "Usage:"
echo "pod_logs dev|test|preprod|prod [pod_name]"
echo ""
echo "If no pod name is defined, the first API pod found will be used"
exit 1
else
environment=$1
fi

namespace="hmpps-community-accommodation-$environment"

if [ -z "$2" ]; then
echo "No pod specified, will use first API pod found"
pod=$(kubectl -n "$namespace" get pods -l app=hmpps-approved-premises-api -o jsonpath='{.items[0].metadata.name}')
else
pod="$2"
fi

echo "Outputting logs for $pod"

kubectl -n $namespace logs "$pod"

0 comments on commit 01e5f54

Please sign in to comment.