Skip to content

Commit 537bfc0

Browse files
blasgettobias.blasge
andauthored
feat: Add release version in k8s overview (#209)
* feat: added release version field in k8s query * feat: added test for release version field * test: removed unnecessary annotation --------- Co-authored-by: tobias.blasge <tobias.blasge@dynatrace.com>
1 parent 4317c6e commit 537bfc0

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ here:
225225
[`dynatrace.kubernetes-deployments`](plugins/dql-backend/src/service/queries.ts).
226226
You can change this query for all cards or override it using a custom query.
227227

228+
_Convention:_ To display the pod's version in Backstage, annotate it using the following key-value pair:
229+
```yaml
230+
app.kubernetes.io/version: <version>
231+
```
232+
228233
### Site Reliability Guardian Validations
229234

230235
Using the `EntityDqlQueryCard` with the queryId `dynatrace.srg-validations`, you

plugins/dql-backend/src/service/queries.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ describe('queries', () => {
9595
// assert
9696
expect(query).toContain('| filter workload.labels[`label`] == "value"');
9797
});
98+
99+
it('should return the query with the version column included', () => {
100+
// act
101+
const query = dynatraceQueries[DynatraceQueryKeys.KUBERNETES_DEPLOYMENTS](
102+
getEntity({
103+
'backstage.io/kubernetes-label-selector': 'label=value',
104+
'backstage.io/kubernetes-namespace': 'namespace',
105+
}),
106+
defaultApiConfig,
107+
);
108+
109+
// assert
110+
expect(query).toContain('| fieldsAdd Version = coalesce(workload.labels[`app.kubernetes.io/version`], "")');
111+
});
98112
});
99113
describe(DynatraceQueryKeys.SRG_VALIDATIONS, () => {
100114
it('should return the srg-query', () => {

plugins/dql-backend/src/service/queries.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ export const dynatraceQueries: Record<
110110
'id',
111111
apiConfig,
112112
)}})
113-
| fieldsRemove id, name, workload.labels, cluster.id, namespace.id
114-
| fieldsAdd Environment = "${apiConfig.environmentName}"`;
113+
| fieldsAdd Environment = "${apiConfig.environmentName}"
114+
| fieldsAdd Version = coalesce(workload.labels[\`app.kubernetes.io/version\`], "")
115+
| fieldsRemove id, name, workload.labels, cluster.id, namespace.id`;
115116
},
116117
[DynatraceQueryKeys.SRG_VALIDATIONS]: (entity, apiConfig) => {
117118
const catalogTags =

0 commit comments

Comments
 (0)