Module
- Harness Continuous Delivery
Environment
- Infrastructure: Kubernetes
- OS: Mac, Windows or Linux
Issue
How to fetch the deployment logs?
Resolution
You can fetch the deployment logs via Harness API mutation exportExecutions
. It provides all the options as Harness Manager.
exportExecutions
includes the following arguments:
clientMutationId: String
filters: [ExecutionFilter!]
Execution filters
notifyOnlyTriggeringUser: Boolean
Notify only the triggering user
userGroupIds: [String!]
User group ids
You will use these arguments to specify the deployment logs you want. You can also use Executionfilter
fields to control which deployments you download and their date range.
Here’s an example that downloads an Application’s deployments and uses the startTime
field to filter:
mutation {
exportExecutions(input: {
clientMutationId: "defaultMutationID"
filters: [
{application: {operator: IN, values: ["esdtWF9jQRewZt7FhM7KTw"]}},
{startTime: {operator: AFTER, value: 1590969600000}},
]
userGroupIds: "defaultGroupID"
}) {
defaultMutationID
defaultID
status
totalExecutions
triggeredAt
downloadLink
expiresAt
errorMessage
}
}
userGroupIds
is used to indicate which Harness User Group to notify via its Notification Settings. You can get the ID using the API queries userGroup
or userGroupByName
or from the Harness Manager URL when looking at the User Group.
Here is the example response:
{
"data": {
"exportExecutions": {
"clientMutationId": “defaultMutationID”,
"requestId": "defaultID",
"status": "QUEUED",
"totalExecutions": 2,
"triggeredAt": 1591390258752,
"downloadLink": "https://pr.harness.io/export-logs/api/export-executions/download/o63US8waSImWhoEnlDAEcg?accountId=kmpySmUISimoRrJL6NL73w",
"expiresAt": 1591660258751,
"errorMessage": null
}
}
}