monitor-cockroachdb.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!--
  2. title: "Monitor CockroachDB metrics with Netdata"
  3. sidebar_label: "Monitor CockroachDB metrics with Netdata"
  4. custom_edit_url: https://github.com/netdata/netdata/edit/master/docs/guides/monitor-cockroachdb.md
  5. learn_status: "Published"
  6. learn_topic_type: "Tasks"
  7. learn_rel_path: "Miscellaneous"
  8. -->
  9. # Monitor CockroachDB metrics with Netdata
  10. [CockroachDB](https://github.com/cockroachdb/cockroach) is an open-source project that brings SQL databases into
  11. scalable, disaster-resilient cloud deployments. Thanks to
  12. a [new CockroachDB collector](/src/go/plugin/go.d/collector/cockroachdb/README.md)
  13. released in
  14. [v1.20](https://blog.netdata.cloud/posts/release-1.20/), you can now monitor any number of CockroachDB databases with
  15. maximum granularity using Netdata. Collect more than 50 unique metrics and put them on interactive visualizations
  16. designed for better visual anomaly detection.
  17. Netdata itself uses CockroachDB as part of its Netdata Cloud infrastructure, so we're happy to introduce this new
  18. collector and help others get started with it straight away.
  19. Let's dive in and walk through the process of monitoring CockroachDB metrics with Netdata.
  20. ## What's in this guide
  21. - [Monitor CockroachDB metrics with Netdata](#monitor-cockroachdb-metrics-with-netdata)
  22. - [What's in this guide](#whats-in-this-guide)
  23. - [Configure the CockroachDB collector](#configure-the-cockroachdb-collector)
  24. - [Manual setup for a local CockroachDB database](#manual-setup-for-a-local-cockroachdb-database)
  25. - [Tweak CockroachDB alerts](#tweak-cockroachdb-alerts)
  26. ## Configure the CockroachDB collector
  27. Because _all_ of Netdata's collectors can auto-detect the services they monitor, you _shouldn't_ need to worry about
  28. configuring CockroachDB. Netdata only needs to regularly query the database's `_status/vars` page to gather metrics and
  29. display them on the dashboard.
  30. If your CockroachDB instance is accessible through `http://localhost:8080/` or `http://127.0.0.1:8080`, your setup is
  31. complete. Restart Netdata with `sudo systemctl restart netdata`, or the appropriate
  32. method for your system, and refresh your browser. You should see CockroachDB
  33. metrics in your Netdata dashboard!
  34. <figure>
  35. <img src="https://user-images.githubusercontent.com/1153921/73564467-d7e36b00-441c-11ea-9ec9-b5d5ea7277d4.png" alt="CPU utilization charts from a CockroachDB database monitored by Netdata" />
  36. <figcaption>CPU utilization charts from a CockroachDB database monitored by Netdata</figcaption>
  37. </figure>
  38. > Note: Netdata collects metrics from CockroachDB every 10 seconds, instead of our usual 1 second, because CockroachDB
  39. > only updates `_status/vars` every 10 seconds. You can't change this setting in CockroachDB.
  40. If you don't see CockroachDB charts, you may need to configure the collector manually.
  41. ### Manual setup for a local CockroachDB database
  42. To configure Netdata's CockroachDB collector, navigate to your Netdata configuration directory (typically at
  43. `/etc/netdata/`) and use `edit-config` to initialize and edit your CockroachDB configuration file.
  44. ```bash
  45. cd /etc/netdata/ # Replace with your Netdata configuration directory, if not /etc/netdata/
  46. ./edit-config go.d/cockroachdb.conf
  47. ```
  48. Scroll down to the `[JOBS]` section at the bottom of the file. You will see the two default jobs there, which you can
  49. edit, or create a new job with any of the parameters listed above in the file. Both the `name` and `url` values are
  50. required, and everything else is optional.
  51. For a production cluster, you'll use either an IP address or the system's hostname. Be sure that your remote system
  52. allows TCP communication on port 8080, or whichever port you have configured CockroachDB's
  53. [Admin UI](https://www.cockroachlabs.com/docs/stable/monitoring-and-alerting.html#prometheus-endpoint) to listen on.
  54. ```yaml
  55. # [ JOBS ]
  56. jobs:
  57. - name: remote
  58. url: http://203.0.113.0:8080/_status/vars
  59. - name: remote_hostname
  60. url: http://cockroachdb.example.com:8080/_status/vars
  61. ```
  62. For a secure cluster, use `https` in the `url` field instead.
  63. ```yaml
  64. # [ JOBS ]
  65. jobs:
  66. - name: remote
  67. url: https://203.0.113.0:8080/_status/vars
  68. tls_skip_verify: yes # If your certificate is self-signed
  69. - name: remote_hostname
  70. url: https://cockroachdb.example.com:8080/_status/vars
  71. tls_skip_verify: yes # If your certificate is self-signed
  72. ```
  73. You can add as many jobs as you'd like based on how many CockroachDB databases you have—Netdata will create separate
  74. charts for each job. Once you've edited `cockroachdb.conf` according to the needs of your infrastructure, restart
  75. Netdata to see your new charts.
  76. <figure>
  77. <img src="https://user-images.githubusercontent.com/1153921/73564469-d7e36b00-441c-11ea-8333-02ba0e1c294c.png" alt="Charts showing a node failure during a simulated test" />
  78. <figcaption>Charts showing a node failure during a simulated test</figcaption>
  79. </figure>
  80. ## Tweak CockroachDB alerts
  81. This release also includes eight pre-configured alerts for live nodes, such as whether the node is live, storage
  82. capacity, issues with replication, and the number of SQL connections/statements. See [health.d/cockroachdb.conf on
  83. GitHub](https://raw.githubusercontent.com/netdata/netdata/master/src/health/health.d/cockroachdb.conf) for details.
  84. You can also edit these files directly with `edit-config`:
  85. ```bash
  86. cd /etc/netdata/ # Replace with your Netdata configuration directory, if not /etc/netdata/
  87. ./edit-config health.d/cockroachdb.conf # You may need to use `sudo` for write privileges
  88. ```
  89. For more information about editing the defaults or writing new alert entities, see our documentation on [configuring health alerts](/src/health/REFERENCE.md).