# cfxdm - dm:filter

**dm:filter:** This cfxdm tag allows the user to apply simple to complex filters on the retrieved data from a different extension / datasource using CFX query language.

This tag is useful when an extension / datasource does not support filtering the data at the source using cfx query language. So, the pre-requisite is to retrieve the data before using this (dm:filter) tag.&#x20;

**dm:filter syntax:**&#x20;

* **dm:filter&#x20;*****\<cfx-ql-query>*****&#x20; :** Use CFX query language to apply the filter. If you do not want to apply any query and to include all of the ingested data, use **'\*'** (without any quotes).
* **dm:filter&#x20;*****\<cfx-ql-query>*****&#x20;get&#x20;*****COLUMN\_Name\_1, COLUMN\_Name\_2, COLUMN\_Name\_3*****&#x20;.... :** Use this syntax to limit the scope to only the selected columns. It also maintains the selected column's specified order.
* **dm:filter&#x20;*****\<cfx-ql-query>*****&#x20;get&#x20;*****COLUMN\_Name\_1*****&#x20;as '*****New\_COLUMN\_Name\_1*****',&#x20;*****COLUMN\_Name\_2*****&#x20;as '*****New\_COLUMN\_Name\_2*****',&#x20;*****COLUMN\_Name\_3*****&#x20;as '*****New\_COLUMN\_Name\_3'*****... :** Use this syntax to limit the scope to only the selected columns and rename them with new column names. It also maintains the selected column's specified order.

{% hint style="info" %}
Please refer [**CFX query language**](https://docs.cloudfabrix.io/cfxql-cfx-query-language) section for detailed information on supported queries and their usage/syntax with examples.
{% endhint %}

In the below example, for reference, we are going to use **VMware vROps** as an extension to query the data and ingest it into **dm:filter** tag for applying the filtering capabilities using CFX query language.

Enter the below command to select **VMware vROps resources tag (@vrops:resources)**. (In this example, vrops name is used as a label to identify VMware vROps extension and it's tags. The label is defined while adding the extension in cfxdx configuration file or through UI.)

```
tag @vrops:resources
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MVAY1Kf5ytXbiiLzPbl%2F-MVAcvT9UuRVaIvsXS51%2FScreen%20Shot%202021-03-06%20at%2011.42.48%20PM.png?alt=media\&token=e7b18e07-3ea8-4e12-b0ff-b7e54d3f566a)

**Example 1:**&#x20;

Get the data from VMware vROps resources tag (@vrops:resources) and modify the column names. Below shown columns (highlighted) are from vROps resource tag.

* **identifier** as Virtual\_Resource\_Identifier
* **name** as Virtual\_Resource\_Name
* **resource\_kind** as Virtual\_Resource\_Type
* **adapter\_kind** as Virtual\_Adapter\_Type

{% hint style="info" %}
**-->** symbol represents piping the data between two extension tags, the output of an extension tag becomes as an input to another extension tag. It is similar to using the pipe (I) command in Unix/Linux OS.
{% endhint %}

```
data --> dm:filter * get identifier as 'Virtual_Resource_Identifier', name as 'Virtual_Resource_Name', resource_kind as 'Virtual_Resource_Type', adapter_kind as 'Virtual_Adapter_Type'
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MVAjpVvMxPcv25RBFUj%2F-MVAklm6fuLKd6JP7Q_z%2FScreen%20Shot%202021-03-07%20at%2012.17.06%20AM.png?alt=media\&token=5128ccad-6466-444f-97d1-d731b6e2de14)

**Example 2:**&#x20;

Get the data from VMware vROps resources tag (@vrops:resources) and filter the data only to selective columns. Below shown (highlighted) are all of the columns from vROps resource tag. Out of them, limit the column selection in a specific order (ex: name, resource\_kind & identifier.... skip adapter\_kind)

* **identifier**
* **name**
* **resource\_kind**
* **adapter\_kind (**&#x73;kip this column from the quer&#x79;**)**

```
data --> dm:filter * get name,resource_kind,identifier
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MVAmjM_mGl7jjDBns5z%2F-MVAoR597sx2l6KHPlrL%2FScreen%20Shot%202021-03-07%20at%2012.32.51%20AM.png?alt=media\&token=c90eea1d-2924-4564-bfc4-8d3c38621b7b)

**Example 3:**&#x20;

Get the data from VMware vROps resources tag (@vrops:resources) and using CFX query language, filter the data that matches '**VirtualMachine**' under column '**resource\_kind**' and limit the column's scope only to name, resource\_kind & identifier.

```
data --> dm:filter resource_kind equals 'VirtualMachine' get name,resource_kind,identifier
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MVAosGoyMIqJJ6DPgOf%2F-MVAqQhDRT-G2CItDbQr%2FScreen%20Shot%202021-03-07%20at%2012.41.51%20AM.png?alt=media\&token=804ad2a4-5218-4177-88f1-98d8b7c6c1ea)

**Example 4:**&#x20;

Get the data from VMware vROps resources tag (@vrops:resources) and using CFX query language, filter the data that matches '**VirtualMachine**' or '**DistributedVirtualPortgroup**' or '**ResourcePool**' and include all of the available columns.

```
data --> dm:filter resource_kind contains 'VirtualMachine|DistributedVirtualPortgroup|ResourcePool'
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MVAqZJr7j9NGAXVa_ye%2F-MVAsiz8s2_odsFNhyxZ%2FScreen%20Shot%202021-03-07%20at%2012.51.35%20AM.png?alt=media\&token=91288952-a94d-4887-ab91-f2e56c101fac)

{% hint style="info" %}
If the **column name** has any **special character** (ex: a dot or dash etc..), then it needs to be escaped with backquotes. For example, the column name is first.name, it should be specified as **\`first.name\`** (**backquote escape**)
{% endhint %}

## **Appendix:**&#x20;

**ServiceNow Examples:**

In this section, we are going to use **ServiceNow** as an extension to query the data and ingest it into the **dm:filter** tag for applying the filtering capabilities using CFX query language.&#x20;

Note: In order for the following examples to work, the main pre-requisite is to add your ServiceNow account details to CFXDX using the CFXDX configuration section.

**Example 1:**&#x20;

Checking the connectivity to the ServiceNow instance via CFXDX.&#x20;

```
> check snow
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MWg77tIdbmeTkpSXYAu%2F-MWg7C7e8GHrA_F8aMO7%2FScreen%20Shot%202021-03-25%20at%206.21.57%20PM.png?alt=media\&token=0c63468d-2e79-4752-9a1e-eb029f48f47a)

**Example 2:**&#x20;

Following ServiceNow tags are available via CFXDX.

```
> tags snow
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MWg7PmgMfY4MUWShtRB%2F-MWg9Pb4ZTuPgeT14Ou3%2FScreen%20Shot%202021-03-25%20at%206.32.14%20PM.png?alt=media\&token=e06b531c-5ced-446c-91cd-30685f4aa878)

**Example 3:**&#x20;

Get the data from the ServiceNow tag (#snow:incidents) and modify the column names. Below shown columns (highlighted) are from the ServiceNow incidents tag.

* **number**
* **short\_description**
* **state**
* **priority**

```
data --> dm:filter * get number as 'Ticket_Number', short_description as 'Description', state as 'State', priority as 'Priority'
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MWg9TN62cJcO-bdJyeb%2F-MWgAnrLgVv-ZkMHi9nT%2FScreen%20Shot%202021-03-25%20at%206.38.06%20PM.png?alt=media\&token=023bda9b-498c-4016-a521-7f5d66e5d481)

**Example 4:**&#x20;

Get the data from ServiceNow tag (#snow:incidents)) and using CFX query language, filter the data that matches '**email**' under column 'short\_descriptio&#x6E;*'* and limit the column's scope only to Number,  Short description. State.

```
data --> dm:filter short_description contains 'email' get number as 'Incident Numnber', short_description as 'Short Description', state as 'State'
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MWgAtkMxda7a_Ln7dVv%2F-MWgCSDW5fYJjQqMVyqJ%2FScreen%20Shot%202021-03-25%20at%206.45.20%20PM.png?alt=media\&token=3efcaab5-9be4-490a-af2b-1df27a040db9)

**Example 5:**&#x20;

Get the data from ServiceNow tag (#snow:incidents)) and using CFX query language, filter the data that matches '**email' or 'laptop' or 'VPN'** under column 'short\_descriptio&#x6E;*'* and limit the column's scope only to Number,  Short description. State.

```
data --> dm:filter short_description contains 'email|VPN|laptop' get number as 'Incident Numnber', short_description as 'Short Description', state as 'State'
```

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MWgCW8QWTkcl7HnpUNy%2F-MWgEEB5NWcZOJei3UTO%2FScreen%20Shot%202021-03-25%20at%206.53.37%20PM.png?alt=media\&token=5d158a59-6d07-4fd3-ace0-611711cd16de)
