Can we set a lot of fields instead multiple measurement?



Generally speaking, the schema is that:

  • measurement1:cpu_load
  • tags:PC_id,CPU_model…
  • fields:value
  • measurement2:memory_load
  • tags:PC_id,Memory_model…
  • fields:value
    and measurement3、4、5…
    My plan is:
  • measurement: PC_status
  • tags:PC_id,PC_model…
  • fields:cpu_load,memory_load,disk_load…and fields can increase dynamically

This plan can reduce series’ count but add multiple fields.I want known is that feasible?

Sorry for my poor English.


I am sure you could accomplish this if you write the data yourself to Influx.

The better question is why are you trying to do this? Is there a specific reason you are trying to reduce the number of measurements/series?

Doing something like this may reduce your total series but I have to imagine it would have a huge performance impact on InfluxDB if you have a ton of data


After several rounds of using influxdb, I have settled on something more like your first model:

An example schema is listed below. The type of sample is defined by the “type” tag, the numeric value is generally stored in the “value” field, and then we add additional tags that may or may not be used as needed depending on the sample type. I’ve found this to be a lot more flexible that having a lot of different value names. With simple data structures like this, it is generally easier to write generic code that does things with data (algorithms, plotting, etc), because the sample format is always the same.


The below schema is defined with Go types, and can be written/read directly using:

// SampleType... are constants used in the Sample.Type field.
const (
        SampleTypeVoltage        = "voltage"
        SampleTypeCurrent        = "current"
        SampleTypeFrequency      = "frequency"
        SampleTypeTemperature    = "temperature"
        SampleTypeHumidity       = "humidity"
        SampleTypeAirflow        = "airflow"
        SampleTypeMoisture       = "moisture"
        SampleTypeDoorOpen       = "doorOpen"
        SampleTypeCPUUsage       = "cpuUsage"
        SampleTypeCPUTemp        = "cpuTemp"
        SampleTypeSysMemoryUsed  = "sysMemoryUsed"
        SampleTypeSysStorageUsed = "sysStorageUsed"
        SampleTypeNetTx          = "netTx"
        SampleTypeNetRx          = "netRx"
        SampleTypeError          = "error" // event
        SampleTypeRule           = "rule"  // event

// DeviceType... are constants that define the type of device
// that collected the data and should be used in the Sample.DeviceType field
const (
        DeviceTypeA = "a"
        DeviceTypeB = "b"

// Sample defines a reading from a sensor, or system metric.
type Sample struct {
        Time     time.Time `influx:"time" json:"time"`
        State    string    `json:"state,omitempty" influx:"state,tag"`
        City     string    `json:"city,omitempty" influx:"city,tag"`
        Facility string    `json:"facility,omitempty" influx:"facility,tag"`
        Floor    string    `json:"floor,omitempty" influx:"floor,tag"`
        Cell     string    `json:"cell,omitempty" influx:"cell,tag"`
        Cage     string    `json:"cage,omitempty" influx:"cage,tag"`
        Aisle    string    `json:"aisle,omitempty" influx:"aisle,tag"`
        SubRack  string    `json:"subRack,omitempty" influx:"subRack,tag"`

        // Type is the metric type (i.e. SampleTypeVoltage)
        Type string `json:"type" influx:"type,tag"`

        // DeviceType is the device that generated the sample (i.e. DeviceTypeAts)
        DeviceType string `json:"deviceType" influx:"deviceType,tag"`

        Interval  string `json:"interval,omitempty" influx:"interval,tag"`
        Partition string `json:"partition,omitempty" influx:"partition,tag"`

        // ID is the the device ID that generated the sample
        ID string `json:"id" influx:"id,tag"`

        // Value is the value of a numeric/boolean metric for this sample
        Value float64 `json:"value,omitempty" influx:"value"`

        // Duration describes the time window over which the sample was collected
        // (if it is an average, etc)
        Duration float64 `json:"duration,omitempty" influx:"duration"`

        // Event is a string describing an event
        Event string `json:"event,omitempty" influx:"event"`


I should make one more comment – with the above schema, we put everything in a single measurement.