community.grafana icon indicating copy to clipboard operation
community.grafana copied to clipboard

mssql datasource

Open ImNtReal opened this issue 1 year ago • 5 comments

SUMMARY

Added support for mssql as a datasource. It might be possible to better support some options, but this is working for me.

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

grafana_datasource

ADDITIONAL INFORMATION

I'm not really sure what to add. I'm using this to add Microsoft SQL Server datasources to Grafana for a tool called SQLWATCH.

ok: [vmdbtest01] => {
    "datasource": {
        "changed": true,
        "datasource": {
            "access": "proxy",
            "basicAuth": false,
            "basicAuthUser": "",
            "database": "SQLWATCH",
            "id": 2,
            "isDefault": false,
            "jsonData": {
                "timeInterval": "5s",
                "tlsAuth": false,
                "tlsAuthWithCACert": false
            },
            "name": "vmdbtest01 SQLWATCH",
            "orgId": 1,
            "readOnly": false,
            "secureJsonFields": {
                "password": true
            },
            "type": "mssql",
            "typeLogoUrl": "",
            "uid": "xxxxx",
            "url": "vmdbtest01.company.com",
            "user": "sqlwatch",
            "version": 1,
            "withCredentials": false
        },
        "diff": {
            "after": {
                "access": "proxy",
                "basicAuth": false,
                "database": "SQLWATCH",
                "isDefault": false,
                "jsonData": {
                    "timeInterval": "5s",
                    "tlsAuth": false,
                    "tlsAuthWithCACert": false
                },
                "name": "vmdbtest01 SQLWATCH",
                "orgId": 1,
                "type": "mssql",
                "url": "vmdbtest01.company.com",
                "user": "sqlwatch",
                "withCredentials": false
            },
            "before": {
                "access": "proxy",
                "basicAuth": false,
                "database": "",
                "isDefault": false,
                "jsonData": {
                    "authenticationType": "Windows Authentication",
                    "connMaxLifetime": 14400,
                    "database": "SQLWATCH",
                    "maxIdleConns": 100,
                    "maxIdleConnsAuto": true,
                    "maxOpenConns": 100,
                    "timeInterval": "5s",
                    "tlsAuth": false,
                    "tlsAuthWithCACert": false
                },
                "name": "vmdbtest01 SQLWATCH",
                "orgId": 1,
                "type": "mssql",
                "url": "vmdbtest01.company.com",
                "user": "",
                "withCredentials": false
            }
        },
        "failed": false,
        "msg": "Datasource vmdbtest01 SQLWATCH updated"
    }
}

ImNtReal avatar Jun 28 '23 17:06 ImNtReal

Just realized I have a typeo in my first commit. There's not a way to fix it here without opening a new PR, is there?

ImNtReal avatar Jun 28 '23 18:06 ImNtReal

Hello @ImNtReal . Thanks for your MR, you can do a git rebase origin main and squash the 2nt commit, then git push your branch --force.

Also, can you add a changelog fragment please ?

seuf avatar Oct 23 '23 08:10 seuf

@seuf sorry it took me so long to get back around to this. I've added a changelog fragment.

ImNtReal avatar Nov 09 '23 22:11 ImNtReal

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (ff49e95) 69.63% compared to head (8e1ab84) 71.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #307      +/-   ##
==========================================
+ Coverage   69.63%   71.06%   +1.42%     
==========================================
  Files           9       18       +9     
  Lines        1166     1863     +697     
  Branches      255      321      +66     
==========================================
+ Hits          812     1324     +512     
- Misses        204      397     +193     
+ Partials      150      142       -8     
Flag Coverage Δ
integration 69.81% <100.00%> (+0.17%) :arrow_up:
sanity 23.70% <0.00%> (?)
units 65.59% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
plugins/modules/grafana_datasource.py 76.71% <100.00%> (+2.64%) :arrow_up:

... and 16 files with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Nov 10 '23 16:11 codecov[bot]

Hey @ImNtReal,

would you mind creating some integration-tests for this PR? :)

rndmh3ro avatar Jan 10 '24 15:01 rndmh3ro