CRUD operations create, read, update and delete measures.
bydbctl
is the command line tool in examples.
Create operation adds a new measure to the database's metadata registry repository. If the measure does not currently exist, create operation will create the schema.
A measure belongs to a unique group. We should create such a group with a catalog CATALOG_MEASURE
before creating a measure.
$ bydbctl group create -f - <<EOF metadata: name: sw_metric catalog: CATALOG_MEASURE resource_opts: shard_num: 2 block_interval: unit: UNIT_HOUR num: 2 segment_interval: unit: UNIT_DAY num: 1 ttl: unit: UNIT_DAY num: 7 EOF
The group creates two shards to store data points. Every day, it would create a segment that will generate a block every 2 hours.
The data in this group will keep 7 days.
Then, the below command will create a new measure:
$ bydbctl measure create -f - <<EOF metadata: name: service_cpm_minute group: sw_metric tag_families: - name: default tags: - name: id type: TAG_TYPE_ID - name: entity_id type: TAG_TYPE_STRING fields: - name: total field_type: FIELD_TYPE_INT encoding_method: ENCODING_METHOD_GORILLA compression_method: COMPRESSION_METHOD_ZSTD - name: value field_type: FIELD_TYPE_INT encoding_method: ENCODING_METHOD_GORILLA compression_method: COMPRESSION_METHOD_ZSTD entity: tag_names: - entity_id interval: 1m EOF
service_cpm_minute
expects to ingest a series of data points with a minute interval.
Get(Read) operation gets a measure's schema.
$ bydbctl measure get -g sw_metric -n service_cpm_minute
Update operation changes a measure's schema.
$ bydbctl measure create -f - <<EOF metadata: name: service_cpm_minute group: sw_metric tagFamilies: - name: searchable tags: - name: trace_id type: TAG_TYPE_STRING entity: tag_names: - entity_id EOF
Delete operation removes a measure's schema.
$ bydbctl measure delete -g sw_metric -n service_cpm_minute
The list operation shows all measures' schema in a group.
$ bydbctl measure list -g sw_metric