Skip to content

Rethink :series_name_for_x configuration #56

Closed
@dmke

Description

@dmke

I'm contemplating to reduce the number of config options for the series this gem writes creates:

https://github.com/influxdata/influxdb-rails/blob/cbfd10b6a9611ae52b202896c98b6ff29e3d0a29/lib/influxdb/rails/configuration.rb#L19-L23

with these default values:

https://github.com/influxdata/influxdb-rails/blob/cbfd10b6a9611ae52b202896c98b6ff29e3d0a29/lib/influxdb/rails/configuration.rb#L63-L67

Reasons

  1. The nomenclature is misleading, it stems from some time ago, when "series name" was the right vocabulary. These attributes actually mean "measurement name". A "series" in InfluxDB 0.9+ means values for a given measurement.
  2. Aggregating across multiple measurements is hard (if not impossible). The current setup needs to send five queries to InfluxDB to get the full picture. The PR Implement render_template & render_partial subscriptions #53 adds three more, and Implement SQL Subscriber #55 will add another.

Proposed change

Let there be only one measurement configurable, say Configuration#measurement_name with default value "rails". What was previously written to different measurements, should now get an additional tag to differentiate the source.

Exemplary change for InfluxDB::Rails::Instrumentation:

@@ def benchmark_for_instrumentation @@
 InfluxDB::Rails.client.write_point \
-  c.series_name_for_instrumentation,
+  c.measurement_name,
   values: {
     value: ((Time.now - start) * 1000).ceil,
   },
   tags:   configuration.tags_middleware.call(
+    series: "instrumentation",
     method: "#{controller_name}##{action_name}",
     server: Socket.gethostname
   )

N.B. Not having a dot in the measurement name also makes writing the queries easier, as it does not need to be escaped, because the from clause may have three incarnations:

  1. FROM <database_name>.<retention_policy_name>.<measurement_name> – full qualified
  2. FROM <database_name>..<measurement_name> – using default retention policy
  3. FROM <measurement_name> – using current database and default retention policy

without paying attention, this does raise an error ("retention policy not found"):

select * from rails.db

By eliminating the dot in the name, it becomes easier:

select * from "rails.db" where ...            -- before: needs escaping
select * from rails where series = 'db' ...   -- after: less escaping

Impact on existing users

Existing data could be migrated, and we should support users in doing so. I've already written a short script to migrate the exception measurement (#43), which could be used as a guide.

Existing tooling will break, but changes should be straightforward. For Grafana users, we could create an "official" dashboard to ease the transition. This is a stretch goal though, so it should go into a separate issue.

Tasks

  • modify README.md
  • change InfluxDB::Rails::Configuration
  • update subscriber classes
  • create upgrade guide for pre-1.0 users

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions