This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
Adds support for rollup query helper based on query range inputs #1780
Open
Harkishen-Singh
wants to merge
7
commits into
feature_metric_rollup
Choose a base branch
from
feat_rollup_resolution_decider
base: feature_metric_rollup
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e1d967f
Adds support to create/delete metric rollups via dataset-config.
Harkishen-Singh 8d1dbbc
Update resolution config and add E2E tests for creation/deletion of r…
Harkishen-Singh 782dad8
Refactor DayDuration -> day.Duation
Harkishen-Singh 5409511
Update tests related to register_metric_view().
Harkishen-Singh 8281a59
Adds support to instrument metric-rollups behaviour
Harkishen-Singh ec7c1d5
Update rollups creation/deletion/updation using dataset-config.
Harkishen-Singh 9e1f5c5
Implement rollup resolution decider for incoming queries.
Harkishen-Singh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package database | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/timescale/promscale/pkg/pgxconn" | ||
"github.com/timescale/promscale/pkg/util" | ||
) | ||
|
||
var ( | ||
caggsRefreshTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: util.PromNamespace, | ||
Subsystem: "sql_database", | ||
Name: "caggs_refresh_total", | ||
Help: "Total number of caggs policy executed.", | ||
}, []string{"refresh_interval"}) | ||
caggsRefreshSuccess = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: util.PromNamespace, | ||
Subsystem: "sql_database", | ||
Name: "caggs_refresh_success", | ||
Help: "Total number of caggs policy executed successfully.", | ||
}, []string{"refresh_interval"}) | ||
) | ||
|
||
func init() { | ||
prometheus.MustRegister(caggsRefreshSuccess, caggsRefreshTotal) | ||
} | ||
|
||
type metricsWithSeries struct { | ||
update func(conn pgxconn.PgxConn) error | ||
} | ||
|
||
var metricSeries = []metricsWithSeries{ | ||
{ | ||
update: func(conn pgxconn.PgxConn) error { | ||
rows, err := conn.Query(context.Background(), ` | ||
SELECT | ||
total_successes, | ||
total_runs, | ||
(config ->> 'refresh_interval')::INTERVAL | ||
FROM timescaledb_information.jobs j | ||
INNER JOIN timescaledb_information.job_stats js ON ( j.job_id = js.job_id AND j.proc_name = 'execute_caggs_refresh_policy') | ||
`) | ||
if err != nil { | ||
return fmt.Errorf("error running instrumentation for execute_caggs_refresh_policy: %w", err) | ||
} | ||
defer rows.Close() | ||
for rows.Next() { | ||
var ( | ||
success, total int64 | ||
refreshInterval time.Duration | ||
) | ||
err = rows.Scan(&success, &total, &refreshInterval) | ||
if err != nil { | ||
return fmt.Errorf("error scanning values for execute_caggs_refresh_policy: %w", err) | ||
} | ||
caggsRefreshSuccess.With(prometheus.Labels{"refresh_interval": refreshInterval.String()}).Set(float64(success)) | ||
caggsRefreshTotal.With(prometheus.Labels{"refresh_interval": refreshInterval.String()}).Set(float64(total)) | ||
} | ||
return nil | ||
}, | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we add
useRollups
tocfg *Config
? It reads a little strange that we have a config struct, but it doesn't have all the config options and we need extra parameters in the signature.I haven't checked, but maybe we can't because we tied our configs, cli flags and their namespaces are structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and we can't because rollup comes from dataset