Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prometheus config and metric sync #82

Merged
merged 11 commits into from
Jul 24, 2024
Merged

Add Prometheus config and metric sync #82

merged 11 commits into from
Jul 24, 2024

Conversation

jrauh01
Copy link
Collaborator

@jrauh01 jrauh01 commented May 21, 2024

Add following to the main branch:

  • Database schema for Prometheus metrics
  • Go schema for Prometheus metrics
  • Sync Prometheus metrics to the database
  • Read Prometheus configs from config.yml

@jrauh01 jrauh01 requested a review from lippserd May 21, 2024 10:03
@jrauh01 jrauh01 self-assigned this May 21, 2024
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label May 21, 2024
@jrauh01 jrauh01 requested review from lippserd and removed request for lippserd May 21, 2024 10:30
)

// PrometheusConfig defines Prometheus configuration.
type PrometheusConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

There is metrics#PrometheusConfig and here internal#PrometheusConfig. The latter can be removed.

}

// Validate checks constraints in the supplied Prometheus configuration and returns an error if they are violated.
func (c *PrometheusConfig) Validate() error {
Copy link
Member

Choose a reason for hiding this comment

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

I would let Validate() always return nil and simply disable metric collection if host is not configured, i.e. empty.

klog.Fatal(errors.Wrap(err, "can't create configuration"))
}

promClient, err := promapi.NewClient(promapi.Config{Address: cfg.Prometheus.Host + ":" + strconv.Itoa(cfg.Prometheus.Port)})
Copy link
Member

Choose a reason for hiding this comment

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

There is utils.JoinHostPort from Icinga Go Library. Also, there should be a reasonable default for the Prometheus port.

go.mod Outdated
go 1.21
go 1.22

toolchain go1.22.2
Copy link
Member

Choose a reason for hiding this comment

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

That can be removed.

@@ -464,7 +464,7 @@ CREATE TABLE config_map (

CREATE TABLE data (
id binary(20) NOT NULL,
name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL,
name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Please revert that change. Will be fixed in main.

fmt.Printf("Warnings: %v\n", warnings)
}
if result == nil {
fmt.Println("No results found")
Copy link
Member

Choose a reason for hiding this comment

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

Remove all such No results found lines.

@lippserd lippserd force-pushed the sync-metrics branch 2 times, most recently from 4c74ace to 3420ebe Compare July 24, 2024 09:54
@lippserd lippserd merged commit dd7e369 into main Jul 24, 2024
13 checks passed
@lippserd lippserd deleted the sync-metrics branch July 24, 2024 09:57
@lippserd lippserd added this to the 0.2.0 milestone Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants