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

sqlserver azuredb=true gives segfault #5456

Closed
mmriis opened this issue Feb 20, 2019 · 7 comments · Fixed by #5467
Closed

sqlserver azuredb=true gives segfault #5456

mmriis opened this issue Feb 20, 2019 · 7 comments · Fixed by #5467
Labels
area/sqlserver bug unexpected problem or unintended behavior panic issue that results in panics from Telegraf
Milestone

Comments

@mmriis
Copy link

mmriis commented Feb 20, 2019

Relevant telegraf.conf:

[[inputs.sqlserver]]
  servers = ["Server=xxx.database.windows.net;Port=1433;Database=xxx;User Id=xxx;Password=xxx;app name=telegraf;log=1;"]
  query_version = 2
  azuredb = true

System info:

Telegraf 1.9.4
AzureSQL Standard

Steps to reproduce:

telegraf -test -debug -config=/etc/telegraf/telegraf.conf

Expected behavior:

...
> sqlserver_performance,counter=Reduced\ Memory\ Grant\ Count,host=telegraf,instance=SeedingGroup,object=SQLServer:Workload\ Group\ Stats,sql_instance=xxx value=0 1550652485000000000
> sqlserver_performance,counter=Request\ Count,host=telegraf,instance=SeedingGroup,object=SQLServer:Workload\ Group\ Stats,sql_instance=xxx value=0 1550652485000000000
> sqlserver_performance,counter=Request\ Count,host=telegraf,instance=SloDTAGroup,object=SQLServer:Workload\ Group\ Stats,sql_instance=xxx value=0 1550652485000000000
....

Actual behavior:

2019-02-20T08:44:40Z I! Starting Telegraf 1.9.4
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x142b968]

goroutine 30 [running]:
github.com/influxdata/telegraf/plugins/inputs/sqlserver.(*SQLServer).accRow(0xc0002e2b80, 0x22969b2, 0x263, 0x1, 0xc0003bc540, 0xc, 0xc, 0x252f720, 0xc000170820, 0x2500620, ...)
/go/src/github.com/influxdata/telegraf/plugins/inputs/sqlserver/sqlserver.go:222 +0x738
github.com/influxdata/telegraf/plugins/inputs/sqlserver.(*SQLServer).gatherServer(0xc0002e2b80, 0xc000250121, 0x86, 0x22969b2, 0x263, 0x1, 0xc0003bc540, 0xc, 0xc, 0x252f720, ...)
/go/src/github.com/influxdata/telegraf/plugins/inputs/sqlserver/sqlserver.go:178 +0x20c
github.com/influxdata/telegraf/plugins/inputs/sqlserver.(*SQLServer).Gather.func1(0xc00018b4b0, 0x252f720, 0xc000170820, 0xc0002e2b80, 0xc000250121, 0x86, 0x22969b2, 0x263, 0x1, 0x0, ...)
/go/src/github.com/influxdata/telegraf/plugins/inputs/sqlserver/sqlserver.go:141 +0xb7
created by github.com/influxdata/telegraf/plugins/inputs/sqlserver.(*SQLServer).Gather
/go/src/github.com/influxdata/telegraf/plugins/inputs/sqlserver/sqlserver.go:139 +0x1e8

shell returned 2

Additional info:

Removing azuredb = true fixes behavior...

@danielnelson danielnelson added bug unexpected problem or unintended behavior panic issue that results in panics from Telegraf area/sqlserver labels Feb 20, 2019
@danielnelson
Copy link
Contributor

The azuredb option essentially adds this query, could you try to run it by hand?

	SELECT TOP(1)
		'sqlserver_azurestats' AS [measurement],
		REPLACE(@@SERVERNAME,'\',':') AS [sql_instance],
		avg_cpu_percent,
		avg_data_io_percent,
		avg_log_write_percent,
		avg_memory_usage_percent,
		xtp_storage_percent,
		max_worker_percent,
		max_session_percent,
		dtu_limit,
		avg_login_rate_percent,
		end_time
	FROM
		sys.dm_db_resource_stats WITH (NOLOCK)
	ORDER BY
		end_time DESC
	OPTION (RECOMPILE)

cc @m82labs

@mmriis
Copy link
Author

mmriis commented Feb 21, 2019

image

It works.

@erik-wramner
Copy link

@mmriis , sorry to barge in on your case, but I've been trying to get this plugin working a long time with SQL Database, see #4222. If it works for you (as it seems to do except for the query above), would you mind sharing how you created the telegraf database user? At least when I tried last time the grants mentioned in the documentation don't work in Azure.

@mmriis
Copy link
Author

mmriis commented Feb 21, 2019

@erik-wramner Didn't create a seperate user for telegraf. Just ran GRANT VIEW DATABASE STATE TO [xxx]

@erik-wramner
Copy link

@mmriis thanks. Just to recap so I haven't missed anything. We have a super admin for the whole server, sa. Then we have a dbo user for each database. It doesn't make sense to grant anything to the super user, so I assume that you have created a dbo user for your specific database with VIEW DATABASE STATE and that you connect with that? Correct? If so I will try again with the latest build and see if it works.

@danielnelson
Copy link
Contributor

@mmriis Could you test the change in #5467 to see if it helps? (don'tt forget to set azuredb = true) Here are some builds, let me know if you need one of the more exotic packages:

@mmriis
Copy link
Author

mmriis commented Feb 25, 2019

@danielnelson it works. Thank you very much!

@mmriis mmriis closed this as completed Feb 25, 2019
@danielnelson danielnelson added this to the 1.9.5 milestone Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sqlserver bug unexpected problem or unintended behavior panic issue that results in panics from Telegraf
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants