-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GHA for testing and releasing promql-to-dd-go image
- Loading branch information
Showing
5 changed files
with
158 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Test, build and publish promql-to-dd-go | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'cloud/observability/promql-to-dd-go/**' | ||
- '!cloud/observability/promql-to-dd-go/examples/**' | ||
- '!cloud/observability/promql-to-dd-go/helm-charts/**' | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
pull_request: | ||
paths: | ||
- 'cloud/observability/promql-to-dd-go/**' | ||
- '!cloud/observability/promql-to-dd-go/examples/**' | ||
- '!cloud/observability/promql-to-dd-go/helm-charts/**' | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/promql-to-dd-go_test.yaml | ||
push: | ||
needs: test | ||
uses: ./.github/workflows/promql-to-dd-go_build-publish.yaml |
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,50 @@ | ||
name: Build and push Docker image | ||
|
||
on: | ||
workflow_call: | ||
|
||
env: | ||
IMAGE_NAME: promql-to-dd-go | ||
|
||
jobs: | ||
push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to registry | ||
# This is where you will update the personal access token to GITHUB_TOKEN | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | ||
|
||
- name: Setup Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=raw,value={{branch}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
- name: Build and Push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: cloud/observability/promql-to-dd-go | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: true |
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,26 @@ | ||
name: Test | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Print build information | ||
run: 'echo head_ref: ${{ github.head_ref }}, ref: ${{ github.ref }}, os: ${{ matrix.os }}' | ||
- uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.20' | ||
- name: build | ||
working-directory: cloud/observability/promql-to-dd-go | ||
run: make build | ||
- name: test | ||
working-directory: cloud/observability/promql-to-dd-go | ||
run: make test |
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
cloud/observability/promql-to-dd-go/cmd/promqltodd/main.go
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,58 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"os" | ||
"time" | ||
|
||
"github.com/temporalio/promql-to-dd-go/datadog" | ||
"github.com/temporalio/promql-to-dd-go/prometheus" | ||
"github.com/temporalio/promql-to-dd-go/worker" | ||
) | ||
|
||
func main() { | ||
set := flag.NewFlagSet("app", flag.ExitOnError) | ||
promURL := set.String("prom-endpoint", "", "Prometheus API endpoint for the server") | ||
serverRootCACert := set.String("server-root-ca-cert", "", "Optional path to root server CA cert") | ||
clientCert := set.String("client-cert", "", "Required path to client cert") | ||
clientKey := set.String("client-key", "", "Required path to client key") | ||
serverName := set.String("server-name", "", "Server name to use for verifying the server's certificate") | ||
insecureSkipVerify := set.Bool("insecure-skip-verify", false, "Skip verification of the server's certificate and host name") | ||
matrixPrefix := set.String("matrix-prefix", "temporal_cloud_", "Prefix of the metrics to be queried and send to Datadog") | ||
stepDuration := set.Int("step-duration-seconds", 60, "The step between metrics") | ||
queryInterval := set.Int("query-interval-seconds", 600, "Interval between each Prometheus query") | ||
|
||
if err := set.Parse(os.Args[1:]); err != nil { | ||
log.Fatalf("failed parsing args: %s", err) | ||
} else if *clientCert == "" || *clientKey == "" { | ||
log.Fatalf("-client-cert and -client-key are required") | ||
} | ||
|
||
datadogClient := datadog.NewAPIClient() | ||
|
||
prometheusClient, err := prometheus.NewAPIClient( | ||
prometheus.Config{ | ||
TargetHost: *promURL, | ||
ServerRootCACert: *serverRootCACert, | ||
ClientCert: *clientCert, | ||
ClientKey: *clientKey, | ||
ServerName: *serverName, | ||
InsecureSkipVerify: *insecureSkipVerify, | ||
}, | ||
) | ||
if err != nil { | ||
log.Fatalf("Failed to create Prometheus client: %s", err) | ||
} | ||
|
||
worker := worker.Worker{ | ||
Querier: prometheusClient, | ||
Submitter: datadogClient, | ||
MetricPrefix: *matrixPrefix, | ||
StepDuration: time.Duration(*stepDuration) * time.Second, | ||
QueryInterval: time.Duration(*queryInterval) * time.Second, | ||
Quantiles: []float64{0.5, 0.9, 0.95, 0.99}, | ||
} | ||
|
||
worker.Run() | ||
} |