# Help with YAML customization for Microsoft SQL Server Extension

**URL:** <https://community.dynatrace.com/t/help-with-yaml-customization-for-microsoft-sql-server-extension/54011>\
**Category:** Extensions\
**Tags:** databases, sql, extensions\
**Created:** [November 6, 2025, 3:14pm UTC](https://community.dynatrace.com/t/help-with-yaml-customization-for-microsoft-sql-server-extension/54011 "2025-11-06T15:14:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao1](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Joao1](https://community.dynatrace.com/u/Joao1)\
**Post date:** [November 6, 2025, 3:14pm UTC](https://community.dynatrace.com/t/help-with-yaml-customization-for-microsoft-sql-server-extension/54011/1 "2025-11-06T15:14:18Z")

</div>

Hi,

If possible, i need help with something related to the YAML of the extension. I was editing it for a custom extension using the same data source. I was trying to edit a query which is used for the database state, to get information for a specific database. My question:

1. I created a variable with perItem: true&nbsp;  
so that i can define it in each endpoint, which is called:

-&nbsp;id:&nbsp;database&nbsp; &nbsp;&nbsp;displayName:&nbsp;Database Name&nbsp; &nbsp;&nbsp;perItem:&nbsp;true&nbsp; &nbsp;&nbsp;type:&nbsp;textthis is the query:

metrics:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&nbsp;key:&nbsp;sql-server.databases.state&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;value:&nbsp;col:state&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;query:&nbsp;\>-&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SELECT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AS database\_name,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state\_desc,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; recovery\_model\_desc,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; user\_access\_desc,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is\_auto\_close\_on,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ISNULL(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DATABASEPROPERTYEX(name, ‘Updateability’),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CASE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is\_read\_only&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHEN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; THEN&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘READ\_WRITE’&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ELSE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘READ\_ONLY’&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; END&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) AS updateability&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FROM&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys.databases&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WHERE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name = 'var:database’I tried it like that with ‘var:database’ and with ${var:database} and both didn’t work. Does anyone know a way to dynamically put the information there?

---

<div class="post-metadata">

**Author:** ![t\_pawlak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/t_pawlak/32/14991_2.png) [@t\_pawlak](https://community.dynatrace.com/u/t_pawlak)\
**Post date:** [November 7, 2025, 12:16pm UTC](https://community.dynatrace.com/t/help-with-yaml-customization-for-microsoft-sql-server-extension/54011/2 "2025-11-07T12:16:53Z")

</div>

Hi,  
I think “trick” should be easy.  
In Extension 2.0&nbsp;you can’t inject variables inside the SQL text. Instead, you run the query “wide” and then filter the dimension using your per-endpoint variable. That’s the supported pattern.  
here is documentation:  
[Extension YAML file](https://docs.dynatrace.com/docs/ingest-from/extensions/develop-your-extensions/extension-yaml)

So, in your yaml:

```markup
vars:
  - id: database
    displayName: Database Name
    perItem: true
    type: text
sqlServer:
  - group: Database state
    query: >-
      SELECT
        name AS database_name,
        state,
        state_desc,
        recovery_model_desc,
        user_access_desc,
        is_auto_close_on,
        ISNULL(
          DATABASEPROPERTYEX(name, 'Updateability'),
          CASE WHEN is_read_only = 0 THEN 'READ_WRITE' ELSE 'READ_ONLY' END
        ) AS updateability
      FROM sys.databases

    # Map the name as a dimension and filter it by the variable
    dimensions:
      - key: mssql.database
        value: col:database_name
        filter: var:database

    metrics:
      - key: sql-server.databases.state
        value: col:state
        type: gauge

```

Then, in each endpoint’s monitoring configuration, set database to the specific DB (e.g., AdventureWorks). The filter will keep only rows where mssql.database equals that value. Filters can use variables (var:\<id\>) or constants and are applied at the dimension level; they don’t rewrite the SQL.  
Please try this and let me know if it works. Unfortunately, I don’t have a way to test it myself.
