<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: filter for Kubernetes label key in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/246301#M919</link>
    <description>&lt;P&gt;Thank you that approach works well. Just needed to remove a blank space in the `&lt;SPAN&gt;parse workload.labels[`com.acme.project `]` line:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;parse workload.labels[`com.acme.project`]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;everything else worked perfectly, thank you again!&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2024 14:11:45 GMT</pubDate>
    <dc:creator>roberto_camp1</dc:creator>
    <dc:date>2024-05-22T14:11:45Z</dc:date>
    <item>
      <title>filter for Kubernetes label key</title>
      <link>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/245740#M895</link>
      <description>&lt;P&gt;I have the following DQL started to detect k8s Deployments with a certain label :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;fetch dt.entity.cloud_application, from: -30m | fields id, workload.id = id, workload.name = entity.name, workload.type = arrayFirst(cloudApplicationDeploymentTypes), workload.labels = cloudApplicationLabels, workload.annotations = kubernetesAnnotations, workload.resourceUid = resourceUid, workload.conditions = kubernetesConditions, workload.age = record(start = resourceCreationTimestamp, end = now()), cluster.id = clustered_by[dt.entity.kubernetes_cluster], namespace.id = belongs_to[dt.entity.cloud_application_namespace], namespace.name = namespaceName&lt;BR /&gt;// Filters: [cluster,namespace,workloadLabels,workloadType]&lt;BR /&gt;| filter in(id, classicEntitySelector("type(CLOUD_APPLICATION),toRelationship.isClusterOfCa(type(KUBERNETES_CLUSTER),entityName.equals(operations))"))&lt;BR /&gt;| filter in(id, classicEntitySelector("type(CLOUD_APPLICATION),toRelationship.isNamespaceOfCa(type(CLOUD_APPLICATION_NAMESPACE),entityName.equals(services))"))&lt;BR /&gt;| filter workload.labels[`com.acme.project`] == "98417"&lt;BR /&gt;| filter in(workload.type, "KUBERNETES_DEPLOYMENT", "OPEN_SHIFT_DEPLOYMENT_CONFIG")&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, instead of doing a filter on the specific label value "98417" for the label key&amp;nbsp;`com.acme.project`, can I simply return all the kubernetes Deployments that have the&amp;nbsp;`com.acme.project` label, regardless of the value of the label?&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 15:04:03 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/245740#M895</guid>
      <dc:creator>roberto_camp1</dc:creator>
      <dc:date>2024-05-15T15:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: filter for Kubernetes label key</title>
      <link>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/246076#M912</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/67600"&gt;@roberto_camp1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It’s possible. You can use Dynatrace Pattern Language(DPL) to match if any value is in com.acme.project variable and if this variable even exist. Then, you can filter the new variable so that it does not have a null value, in case the com.acme.project variable does not exist, the new variable will have a null value. In your example you can do something like this:&lt;/P&gt;&lt;P&gt;fetch dt.entity.cloud_application, from: -30m | fields id, workload.id = id, workload.name = entity.name, workload.type = arrayFirst(cloudApplicationDeploymentTypes), workload.labels = cloudApplicationLabels, workload.annotations = kubernetesAnnotations, workload.resourceUid = resourceUid, workload.conditions = kubernetesConditions, workload.age = record(start = resourceCreationTimestamp, end = now()), cluster.id = clustered_by[dt.entity.kubernetes_cluster], namespace.id = belongs_to[dt.entity.cloud_application_namespace], namespace.name = namespaceName&lt;BR /&gt;// Filters: [cluster,namespace,workloadLabels,workloadType]&lt;BR /&gt;| filter in(id, classicEntitySelector("type(CLOUD_APPLICATION),toRelationship.isClusterOfCa(type(KUBERNETES_CLUSTER),entityName.equals(operations))"))&lt;BR /&gt;| filter in(id, classicEntitySelector("type(CLOUD_APPLICATION),toRelationship.isNamespaceOfCa(type(CLOUD_APPLICATION_NAMESPACE),entityName.equals(services))"))&lt;BR /&gt;&lt;SPAN&gt;| parse workload.labels[`com.acme.project `], """DATA:com.acme.project"""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| filter isNotNull(com.acme.project)&lt;/SPAN&gt;&lt;BR /&gt;| filter in(workload.type, "KUBERNETES_DEPLOYMENT", "OPEN_SHIFT_DEPLOYMENT_CONFIG")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope it will help,&lt;/P&gt;&lt;P&gt;Bests&lt;BR /&gt;Michal&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 11:32:35 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/246076#M912</guid>
      <dc:creator>MichalOlszewski</dc:creator>
      <dc:date>2024-05-20T11:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: filter for Kubernetes label key</title>
      <link>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/246301#M919</link>
      <description>&lt;P&gt;Thank you that approach works well. Just needed to remove a blank space in the `&lt;SPAN&gt;parse workload.labels[`com.acme.project `]` line:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;parse workload.labels[`com.acme.project`]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;everything else worked perfectly, thank you again!&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 14:11:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/filter-for-Kubernetes-label-key/m-p/246301#M919</guid>
      <dc:creator>roberto_camp1</dc:creator>
      <dc:date>2024-05-22T14:11:45Z</dc:date>
    </item>
  </channel>
</rss>

