Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Microsoft SQL Server Source #208

Open
titt opened this issue May 30, 2024 · 1 comment
Open

Support Microsoft SQL Server Source #208

titt opened this issue May 30, 2024 · 1 comment
Labels
plugin Support for plugins

Comments

@titt
Copy link

titt commented May 30, 2024

Currently, there are no query target helpers/functions for Microsoft SQL Server.
It would be great to support Microsoft SQL Server as this data source is quite popular.

@Duologic Duologic added the plugin Support for plugins label May 30, 2024
@titt
Copy link
Author

titt commented Jun 3, 2024

I have created a short workaround by adding some file in the code deployed by the jb install:

  • vendor\custom\query\sql.libsonnet
local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet';

{
  '#new':: d.func.new(
    'Creates a new Microsoft SQL Server query target for panels.',
    args=[
      d.arg('datasource', d.T.string),
	  d.arg('rawSql', d.T.string),
	  d.arg('format', d.T.string),
	  d.arg('rawEditor', d.T.bolean),
	  d.arg('rawQuery', d.T.bolean),
      d.arg('queryText', d.T.string),  
    ]
  ),
  new(datasource, rawSql, format='time_series', rawEditor=true, rawQuery=true, queryText=rawSql):
    self.withDatasource(datasource)
    + {
		format: format,
		rawSql: rawSql,
		rawEditor: rawEditor,
		rawQuery: rawQuery,
		queryText: queryText,
	  },

  '#withDatasource':: d.func.new(
    'Set the datasource for this query.',
    args=[
      d.arg('value', d.T.string),
    ]
  ),
  withDatasource(value): {
    datasource+: {
      type: 'Microsoft SQL Server',
      uid: value,
    },
  },
  '#withDatasourceMixin':: { ignore: true },
}
  • vendor/query.libsonnet
 // This file is generated, do not manually edit.
{
  '#': { help: 'grafonnet.query', name: 'query' },
  azureMonitor: import 'query/azureMonitor.libsonnet',
  cloudWatch: import 'query/cloudWatch.libsonnet',
  elasticsearch: import 'query/elasticsearch.libsonnet',
  expr: import 'query/expr.libsonnet',
  googleCloudMonitoring: import 'query/googleCloudMonitoring.libsonnet',
  grafanaPyroscope: import 'query/grafanaPyroscope.libsonnet',
  loki: import 'query/loki.libsonnet',
  parca: import 'query/parca.libsonnet',
  prometheus: import 'query/prometheus.libsonnet',
  tempo: import 'query/tempo.libsonnet',
  testData: import 'query/testData.libsonnet',
  sql: import 'query/sql.libsonnet'
}
  • \vendor\query\sql.libsonnet
// This file is generated, do not manually edit.
{
  '#': { help: 'grafonnet.query.sql', name: 'sql' },
  '#withDatasource': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['object'] }], help: "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" } },
  withDatasource(value): {
    datasource: value,
  },
  '#withDatasourceMixin': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['object'] }], help: "For mixed data sources the selected datasource is on the query level.\nFor non mixed scenarios this is undefined.\nTODO find a better way to do this ^ that's friendly to schema\nTODO this shouldn't be unknown but DataSourceRef | null" } },
  withDatasourceMixin(value): {
    datasource+: value,
  },
}
+ (import '../custom/query/sql.libsonnet')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin Support for plugins
Projects
None yet
Development

No branches or pull requests

2 participants