Monitorare SQL Server può diventare un affare decisamente costoso. Certo, sul mercato ci sono moltissime soluzioni a pagamento, ma che fare se le istanze sono molte e i soldi sono pochi?
In questa sessione combineremo diversi strumenti open source (InfluxDB, Telegraf , Grafana, DbaTools and many more) per raccogliere metriche di performance significative, analizzare i dati raccolti, creare degli alert per gli eventi critici, fare troubleshooting dei problemi e pianificare le risorse per il futuro. Raggiungimi in questa sessione e vedrai che il monitoring non è un business per milionari.
By Gianluca Sartori
4. Gianluca Sartori
Independent SQL Server consultant
SQL Server MVP, MCTS, MCITP, MCT
Works with SQL Server since version 7
DBA @ Scuderia Ferrari
Blog: spaghettidba.com
Twitter: @spaghettidba
5. AGENDA
• What we need
• What the market offers
• What SQL Server offers
• What the community offers
• The TICK stack
• How you do it
7. MONITORING
• Troubleshooting
What happened tonight at 03:40?
• Tune performance
Which queries consume most resources?
• Capacity Planning
How fast are my databases growing?
• Baselining
Is the system behaving normally?
• Alerting
Hey, look: something’s wrong here!
8. WHAT THE MARKET OFFERS
Buy a product
• Big value
• Big money $$
9. WHAT SQL SERVER OFFERS
Use SQL Server built-in tools
• SQLTrace
• Extended Events
• Alerts
• Activity Monitor
• SSMS Reports
• Data Collector
10. SQL SERVER DATA COLLECTOR
PROS:
• Included in SQL Server
• Offers some reports
• Good for troubleshooting
CONS:
• Unreliable
• Slow
• No alerting
• Hard to customize/extend
• Deprecated
14. Time series database
Written in GO
Designed to store time series data
Offers two query languages
• InfluxQL - similar to SQL
• Flux - inspired by Javascript / LINQ
15. Data collection agent
Can monitor several information sources:
• Operating system
• Databases
• Network
• Message Queues
• Apps
• …
Works with plugins
Over 100 plugins
• Apache
• Cassandra
• Docker
• Elasticsearch
• Graylog
• ….
• SQL Server!
16. Administration interface for Influxdb
User Interface for Kapacitor
Can be used to explore data
Can create dashboards to visualize data
Can set up and manage alerts in Kapacitor
17. Data processing engine
Can publish data to topics
Handlers subscribe to topics and perform actions
Alerts can be sent to several channels, using plugins
• Email
• Slack
• …
18. Monitoring / analytics platform
Native Influxdb support
More data sources supported via plugins
Easy dashboard creation
Multiple built-in / community dashboards
21. 1. Download Influxdb
2. Unzip the archive (c:tick maybe?)
3. Run influxD.exe
• Open port in FW (default 8086)
• Run it as a service maybe?
22. Ever used srvany? You get why NSSM then…
1. Download NSSM
2. Unzip the archive (c:tick maybe?)
3. nssm install influxdb
23. 1. Download Telegraf
2. Unzip the archive (c:tick maybe?)
3. Generate and edit the config file
• Log
• Input
• Output
24. 1. Download Chronograf
2. Unzip the archive
3. Install as a service
4. Open in browser
• Create a connection
• Create dashboards
• Explore the data
25. Influx DB entity SQL DB entity
Measurements Tables
Tags Columns (indexed)
Fields Columns (not indexed)
Points Rows
•Tags are indexed, and are used to filter and aggregate data
=> view CPU usage (the Field) by host (the context)
•Fields are not indexed and should only be aggregated.
A field should represent a metric.
=> CPU usage
26. 1. Download Grafana
2. Unzip the archive
3. Install as a service
4. Open in browser
• Create a connection to Influxdb
• Create (or downlad) dashboards
• Explore the data
27. 1. Configure alerts by dashboard
2. Multiple channels available
• Email
• Slack
• Teams
• Telegram
• …
28. Continuous Queries
• Scheduled queries in InfluxQL
• Provide downsampling and aggregation of data
• Can write to a different retention policy
CREATE CONTINUOUS QUERY "cq_basic" ON "transportation"
BEGIN
SELECT mean("passengers") INTO "average_passengers"
FROM "bus_data" GROUP BY time(1h)
END