Skip to content

Commit

Permalink
Remove RangeResolution scalar (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac authored Sep 30, 2024
1 parent 297f677 commit 3d45dd1
Show file tree
Hide file tree
Showing 34 changed files with 1,094 additions and 1,171 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: hasura/ndc-prometheus
DOCKER_CLI_IMAGE_NAME: hasura/ndc-prometheus-cli

jobs:
tests:
Expand Down Expand Up @@ -47,21 +46,6 @@ jobs:
labels: ${{ steps.docker-metadata.outputs.labels }}
platforms: linux/amd64,linux/arm64

- name: Extract metadata (tags, labels) for the CLI
id: docker-metadata-cli
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_CLI_IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.docker-metadata-cli.outputs.tags }}
labels: ${{ steps.docker-metadata-cli.outputs.labels }}
file: Dockerfile.cli
platforms: linux/amd64,linux/arm64

build-cli-binaries:
name: build the CLI binaries
runs-on: ubuntu-latest
Expand Down
18 changes: 0 additions & 18 deletions Dockerfile.cli

This file was deleted.

11 changes: 4 additions & 7 deletions connector-definition/.hasura-connector/connector-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ supportedEnvironmentVariables:
description: The connection URL to the Prometheus server
required: true
commands:
update:
type: Dockerized
dockerImage: ghcr.io/hasura/ndc-prometheus-cli:{{VERSION}}
commandArgs: ["update"]
update: ndc-prometheus update
cliPlugin:
type: Docker
dockerImage: ghcr.io/hasura/ndc-prometheus-cli:{{VERSION}}
name: ndc-prometheus
version: {{VERSION}}
dockerComposeWatch:
# copy config files into the existing container and restart it
- path: ./configuration.yaml
target: /etc/connector/configuration.yaml
action: sync+restart
action: sync+restart
32 changes: 13 additions & 19 deletions connector/metadata/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ import (
type ScalarName string

const (
ScalarBoolean ScalarName = "Boolean"
ScalarInt64 ScalarName = "Int64"
ScalarFloat64 ScalarName = "Float64"
ScalarString ScalarName = "String"
ScalarDecimal ScalarName = "Decimal"
ScalarTimestamp ScalarName = "Timestamp"
ScalarLabelSet ScalarName = "LabelSet"
ScalarDuration ScalarName = "Duration"
ScalarRangeResolution ScalarName = "RangeResolution"
ScalarJSON ScalarName = "JSON"
ScalarBoolean ScalarName = "Boolean"
ScalarInt64 ScalarName = "Int64"
ScalarFloat64 ScalarName = "Float64"
ScalarString ScalarName = "String"
ScalarDecimal ScalarName = "Decimal"
ScalarTimestamp ScalarName = "Timestamp"
ScalarLabelSet ScalarName = "LabelSet"
ScalarDuration ScalarName = "Duration"
ScalarJSON ScalarName = "JSON"
)

const (
Expand Down Expand Up @@ -70,12 +69,7 @@ var defaultScalars = map[string]schema.ScalarType{
string(ScalarDuration): {
AggregateFunctions: schema.ScalarTypeAggregateFunctions{},
ComparisonOperators: map[string]schema.ComparisonOperatorDefinition{},
Representation: schema.NewTypeRepresentationString().Encode(),
},
string(ScalarRangeResolution): {
AggregateFunctions: schema.ScalarTypeAggregateFunctions{},
ComparisonOperators: map[string]schema.ComparisonOperatorDefinition{},
Representation: schema.NewTypeRepresentationString().Encode(),
Representation: schema.NewTypeRepresentationJSON().Encode(),
},
string(ScalarTimestamp): {
AggregateFunctions: schema.ScalarTypeAggregateFunctions{},
Expand Down Expand Up @@ -238,7 +232,7 @@ var defaultObjectTypes = map[string]schema.ObjectType{
},
"range": schema.ObjectField{
Description: utils.ToPtr("The range value"),
Type: schema.NewNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNamedType(string(ScalarDuration)).Encode(),
},
},
},
Expand All @@ -251,7 +245,7 @@ var defaultObjectTypes = map[string]schema.ObjectType{
},
"range": schema.ObjectField{
Description: utils.ToPtr("The range value"),
Type: schema.NewNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNamedType(string(ScalarDuration)).Encode(),
},
},
},
Expand All @@ -264,7 +258,7 @@ var defaultObjectTypes = map[string]schema.ObjectType{
},
"range": schema.ObjectField{
Description: utils.ToPtr("The range value"),
Type: schema.NewNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNamedType(string(ScalarDuration)).Encode(),
},
},
},
Expand Down
38 changes: 19 additions & 19 deletions connector/metadata/promql.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ func createPromQLFunctionObjectFields(name string, labelEnumScalarName string) s
},
string(AbsentOverTime): schema.ObjectField{
Description: utils.ToPtr("Returns an empty vector if the range vector passed to it has any elements (floats or native histograms) and a 1-element vector with the value 1 if the range vector passed to it has no elements"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Ceil): schema.ObjectField{
Description: utils.ToPtr("Rounds the sample values of all elements in v up to the nearest integer value greater than or equal to v"),
Type: schema.NewNullableNamedType(string(ScalarBoolean)).Encode(),
},
string(Changes): schema.ObjectField{
Description: utils.ToPtr("Returns the number of times its value has changed within the provided time range as an instant vector"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Clamp): schema.ObjectField{
Description: utils.ToPtr("Clamps the sample values of all elements in v to have a lower limit of min and an upper limit of max"),
Expand All @@ -117,11 +117,11 @@ func createPromQLFunctionObjectFields(name string, labelEnumScalarName string) s
},
string(Delta): schema.ObjectField{
Description: utils.ToPtr("Calculates the difference between the first and last value of each time series element in a range vector v, returning an instant vector with the given deltas and equivalent labels"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Derivative): schema.ObjectField{
Description: utils.ToPtr("Calculates the per-second derivative of the time series in a range vector v, using simple linear regression"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Exponential): schema.ObjectField{
Description: utils.ToPtr("Calculates the exponential function for all elements in v"),
Expand Down Expand Up @@ -165,15 +165,15 @@ func createPromQLFunctionObjectFields(name string, labelEnumScalarName string) s
},
string(IDelta): schema.ObjectField{
Description: utils.ToPtr("Calculates the difference between the last two samples in the range vector v, returning an instant vector with the given deltas and equivalent labels"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Increase): schema.ObjectField{
Description: utils.ToPtr("Calculates the increase in the time series in the range vector. Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(IRate): schema.ObjectField{
Description: utils.ToPtr("Calculates the per-second instant rate of increase of the time series in the range vector. This is based on the last two data points"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(LabelJoin): schema.ObjectField{
Description: utils.ToPtr("Joins all the values of all the src_labels using separator and returns the timeseries with the label dst_label containing the joined value"),
Expand Down Expand Up @@ -201,11 +201,11 @@ func createPromQLFunctionObjectFields(name string, labelEnumScalarName string) s
},
string(Rate): schema.ObjectField{
Description: utils.ToPtr("Calculates the per-second average rate of increase of the time series in the range vector"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Resets): schema.ObjectField{
Description: utils.ToPtr("Returns the number of counter resets within the provided time range as an instant vector"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Round): schema.ObjectField{
Description: utils.ToPtr("Rounds the sample values of all elements in v to the nearest integer"),
Expand Down Expand Up @@ -245,47 +245,47 @@ func createPromQLFunctionObjectFields(name string, labelEnumScalarName string) s
},
string(AvgOverTime): schema.ObjectField{
Description: utils.ToPtr("The average value of all points in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(MinOverTime): schema.ObjectField{
Description: utils.ToPtr("The minimum value of all points in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(MaxOverTime): schema.ObjectField{
Description: utils.ToPtr("The maximum value of all points in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(SumOverTime): schema.ObjectField{
Description: utils.ToPtr("The sum of all values in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(CountOverTime): schema.ObjectField{
Description: utils.ToPtr("The count of all values in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(QuantileOverTime): schema.ObjectField{
Description: utils.ToPtr("The φ-quantile (0 ≤ φ ≤ 1) of the values in the specified interval"),
Type: schema.NewNullableNamedType(objectName_QuantileOverTimeInput).Encode(),
},
string(StddevOverTime): schema.ObjectField{
Description: utils.ToPtr("The population standard deviation of the values in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(StdvarOverTime): schema.ObjectField{
Description: utils.ToPtr("The population standard variance of the values in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(LastOverTime): schema.ObjectField{
Description: utils.ToPtr("The most recent point value in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(PresentOverTime): schema.ObjectField{
Description: utils.ToPtr("The value 1 for any series in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(MadOverTime): schema.ObjectField{
Description: utils.ToPtr("The median absolute deviation of all points in the specified interval"),
Type: schema.NewNullableNamedType(string(ScalarRangeResolution)).Encode(),
Type: schema.NewNullableNamedType(string(ScalarDuration)).Encode(),
},
string(Acos): schema.ObjectField{
Description: utils.ToPtr("Calculates the arccosine of all elements in v"),
Expand Down
Loading

0 comments on commit 3d45dd1

Please sign in to comment.