Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions helper/rollup/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/tls"
"encoding/json"
"strconv"
"strings"
"time"

Expand All @@ -18,8 +17,8 @@ type rollupRulesResponseRecord struct {
RuleType RuleType `json:"rule_type"`
Regexp string `json:"regexp"`
Function string `json:"function"`
Age string `json:"age"`
Precision string `json:"precision"`
Age uint64 `json:"age"`
Precision uint64 `json:"precision"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the ones still using CH pre 25.8? I think the best is to set output_format_json_quote_64bit_integers to false on the connection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People can also update their software^... At least when this is also in the next LTS release I think graphite-clickhouse should be compatible with it without any extra configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, 25.8 is a LTS release.

As I said. In my opinion, the software should work without any extra config params in the connection string, or server settings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, therefore I suggested that G-CH would add the option to the connection, not that the user should add it (unless for now until G-CH is fixed).

IsDefault int `json:"is_default"`
}
type rollupRulesResponse struct {
Expand All @@ -39,17 +38,7 @@ func parseJson(body []byte) (*Rules, error) {
}

makeRetention := func(d *rollupRulesResponseRecord) (Retention, error) {
age, err := strconv.ParseInt(d.Age, 10, 32)
if err != nil {
return Retention{}, err
}

prec, err := strconv.ParseInt(d.Precision, 10, 32)
if err != nil {
return Retention{}, err
}

return Retention{Age: uint32(age), Precision: uint32(prec)}, nil
return Retention{Age: uint32(d.Age), Precision: uint32(d.Precision)}, nil
Copy link
Contributor

@Hipska Hipska Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also update Retention to contain uint64 instead?
The makeRetention function could probably also be removed since it's not doing anything special anymore.

}

last := func() *Pattern {
Expand All @@ -70,7 +59,7 @@ func parseJson(body []byte) (*Rules, error) {
defaultFunction = d.Function
}

if d.Age != "" && d.Precision != "" && d.Precision != "0" {
if d.Precision != 0 {
rt, err := makeRetention(&d)
if err != nil {
return nil, err
Expand All @@ -88,7 +77,7 @@ func parseJson(body []byte) (*Rules, error) {
})
}

if d.Age != "" && d.Precision != "" && d.Precision != "0" {
if d.Precision != 0 {
rt, err := makeRetention(&d)
if err != nil {
return nil, err
Expand Down
56 changes: 28 additions & 28 deletions helper/rollup/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,50 +49,50 @@ func TestParseJson(t *testing.T) {
{
"regexp": "^hourly",
"function": "",
"age": "0",
"precision": "3600",
"age": 0,
"precision": 3600,
"is_default": 0
},
{
"regexp": "^hourly",
"function": "",
"age": "3600",
"precision": "13600",
"age": 3600,
"precision": 13600,
"is_default": 0
},
{
"regexp": "^live",
"function": "",
"age": "0",
"precision": "1",
"age": 0,
"precision": 1,
"is_default": 0
},
{
"regexp": "total$",
"function": "sum",
"age": "0",
"precision": "0",
"age": 0,
"precision": 0,
"is_default": 0
},
{
"regexp": "min$",
"function": "min",
"age": "0",
"precision": "0",
"age": 0,
"precision": 0,
"is_default": 0
},
{
"regexp": "max$",
"function": "max",
"age": "0",
"precision": "0",
"age": 0,
"precision": 0,
"is_default": 0
},
{
"regexp": "",
"function": "max",
"age": "0",
"precision": "60",
"age": 0,
"precision": 60,
"is_default": 1
}
],
Expand Down Expand Up @@ -162,48 +162,48 @@ func TestParseJsonTyped(t *testing.T) {
"rule_type": "all",
"regexp": "^hourly",
"function": "",
"age": "0",
"precision": "3600",
"age": 0,
"precision": 3600,
"is_default": 0
},
{
"rule_type": "all",
"regexp": "^hourly",
"function": "",
"age": "3600",
"precision": "13600",
"age": 3600,
"precision": 13600,
"is_default": 0
},
{
"rule_type": "all",
"regexp": "^live",
"function": "",
"age": "0",
"precision": "1",
"age": 0,
"precision": 1,
"is_default": 0
},
{
"rule_type": "plain",
"regexp": "total$",
"function": "sum",
"age": "0",
"precision": "0",
"age": 0,
"precision": 0,
"is_default": 0
},
{
"rule_type": "plain",
"regexp": "min$",
"function": "min",
"age": "0",
"precision": "0",
"age": 0,
"precision": 0,
"is_default": 0
},
{
"rule_type": "plain",
"regexp": "max$",
"function": "max",
"age": "0",
"precision": "0",
"age": 0,
"precision": 0,
"is_default": 0
},
{
Expand All @@ -220,8 +220,8 @@ func TestParseJsonTyped(t *testing.T) {
"rule_type": "all",
"regexp": "",
"function": "max",
"age": "0",
"precision": "60",
"age": 0,
"precision": 60,
"is_default": 1
}
],
Expand Down
Loading