Extensions
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom JDBC Extension

Das-Niharika
Participant

Hi , I am creating a custom jdbc extension using Extension creator. where I have to pass the query and a Go statement in the next line . Below is my yaml.

I have deployed it . Created the monitoring configuration . But the status shows a warning saying that Query has failed: Incorrect syntax near 'Go'. How can I pass multiline query here ? This is for Sybase query so it ways needs a Go statement after the query.

Can someone pls help ?

name: "custom:sybase-vipserver"
minDynatraceVersion: "1.303.0"
author:
  name: "Custom Extensions Creator App"
version: "1.0.1"
jdbc:
  driverClassName: "com.sybase.jdbc4.jdbc.SybDriver"
  validationQuery: "SELECT 1"
  versionQuery: "SELECT 1"
  connectionStringPattern: "^jdbc:sybase:.*$"
  connectionStringPatternErrorMessage: "The connection string must be a valid JDBC
    sybase connection string starting with 'jdbc:sybase:', check:
    c39001.0605/html/prjdbc/prjdbc14.htm"
  errorMessage: "An error occurred while trying to connect to the database. Please
    check the connection details and try again."
  groups:
    - group: "SybaseDatabases"
      featureSet: "databases"
      query: "select @@servername  + ' connection successful' as 'ActiveServer'\

        \ Go"
      timeout: "60"
      metrics:
        - key: "sybase.vipserver"
          value: "col:ActiveServer"
      dimensions:
        - key: "database"
          value: "col:database"
8 REPLIES 8

sujit_k_singh
Champion

@Das-Niharika 

I would say don’t use GO. It’s not valid SQL for the database engine—GO is just a client-side batch separator used by tools like isql/sqsh/DBArtisan. The Dynatrace JDBC extension sends your query straight to the JDBC driver, so the server sees the literal text “Go” and errors out

Use a YAML multiline block and remove GO

Thanks,

Sujit K Singh

Dynatrace Professional Certified

Hi @sujit_k_singh ,

Thanks for your response . I have removed GO . When you say 'use a YAML multiline code' is this the below change in red  what is expected ? if so , after deploying this it throws a warning message saying  Endpoint jdbc:sybase:Tds:10.39.33.11:2138?ENABLE_SSL=true&SSL_TRUST_ALL_CERTS=true&CHARSET=iso_1&CHARSET=iso_1&DYNAMIC_PREPARE=false group 'SybaseDatabases' did not produce any metrics. Subgroups will not be polled.

name: "custom:sybase-vipserver"
minDynatraceVersion: "1.303.0"
author:
  name: "Custom Extensions Creator App"
version: "1.0.5"
jdbc:
  driverClassName: "com.sybase.jdbc4.jdbc.SybDriver"
  validationQuery: "SELECT 1"
  versionQuery: "SELECT 1"
  connectionStringPattern: "^jdbc:sybase:.*$"
  connectionStringPatternErrorMessage: "The connection string must be a valid JDBC
    sybase connection string starting with 'jdbc:sybase:', check:
    c39001.0605/html/prjdbc/prjdbc14.htm"
  errorMessage: "An error occurred while trying to connect to the database. Please
    check the connection details and try again."
  groups:
    - group: "SybaseDatabases"
      featureSet: "databases"
      query: |
        select @@servername  + ' connection successful' as 'ActiveServer'
      timeout: "60"
      metrics:
        - key: "sybase.vipserver"
          value: "col:ActiveServer"
      dimensions:
        - key: "database"
          value: "col:database"

Hi @Das-Niharika 

Endpoint … group 'SybaseDatabases' did not produce any metrics. Subgroups will not be polled.

usually means the query ran but Dynatrace couldn’t map any numeric value to a metric (or the result set didn’t match the mappings), so the group yielded zero metrics.

Can you add this 

groups:
  - group: "SybaseDatabases"
    featureSet: "databases"
    query: |
      select
        1 as value,
        @@servername + ' connection successful' as ActiveServer,
        db_name() as database
    timeout: "60"
    metrics:
      - key: "sybase.vipserver"
        value: "col:value"
    dimensions:
      - key: "active_server"
        value: "col:ActiveServer"
      - key: "database"
        value: "col:database"
 
If you still get the “did not produce any metrics” warning after this, grab the extension execution logs for that endpoint.
Dynatrace Professional Certified

Hi @sujit_k_singh - This is the query executed in sybase side . They use "go" to execute the code.

Hi @Das-Niharika ,

Thanks for checking that and for sharing your side.

 Just to clarify the confusion around the “GO” keyword:

In Sybase tools like isql, DBArtisan, and similar SQL clients, GO is handled by the client, not by the Sybase database itself. The client splits the script into separate batches before sending them to Sybase.

When using JDBC (Dynatrace JDBC‑based extensions), the text is sent exactly as written straight to the Sybase server. Since the Sybase server does not understand “GO”, it fails if GO is included.

So both things can appear “true” at the same time:

GO works in SQL tools because the client removes it.

GO does not work in JDBC because it reaches the Sybase server unchanged.

Dynatrace Professional Certified

Thanks a lot @sujit_k_singh - Without "go" it worked . The issue was - I was trying the get the string value in metric . Seems the only the integer value can be assigned to metric and column value (string type) should be assigned to dimension.

I have another issue . I want to customize my query passed in yaml . it should read from connectionstring  that is passed and return a value .

Currently it the query is 

select count(@@servername) as 'ActiveServerCount', @@servername as
        'ActiveServer

 I want to do something like this . Read from connection string , if the hostname is for example - 'syb_hadr_aimmport_tst.nml.com' then return 'TDS_SY140'

Something similar to below - 

select count(@@servername) as 'ActiveServerCount', @@servername as 'ActiveServer , <read from connection string . if hostname is  syb_hadr_aimmport_tst.nml.com return the value as 'TDS_SY140' as 'VIP server' >

Hi @Das-Niharika 

Thanks for the update — great to hear it worked after removing GO. And yes, metrics must come from a numeric column; strings should be mapped as dimensions.

About “reading from the connection string”: the SQL running on Sybase can’t see the JDBC URL used by Dynatrace. That lives on the client side, not inside the database session.

The SQL alone isn’t enough. In JDBC extensions, Dynatrace requires at least one numeric column to be explicitly mapped as a metric; string columns must be mapped as dimensions. Without that mapping, the group executes but produces no metrics.
Dynatrace Professional Certified

sujit_k_singh
Champion

@Das-Niharika 

can you try this, SQL + mapping

Syb.png
 
Mapping
metrics:
  - key: "sybase.vipserver"
    value: "col:value"

 

dimensions:
  - key: "active_server"
    value: "col:ActiveServer"
  - key: "vip_server"
    value: "col:VIPServer"
Dynatrace Professional Certified

Featured Posts