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

Feat/latency check #19

Merged
merged 17 commits into from
Nov 30, 2023
Merged

Feat/latency check #19

merged 17 commits into from
Nov 30, 2023

Conversation

niklastreml
Copy link
Contributor

@niklastreml niklastreml commented Nov 24, 2023

Motivation

Implements a latency check, that checks whether an endpoint is reachable and collects Timing metrics.

Config file

The check has the following config options:

checks:
  latency:
    enabled: true
    interval: 1
    timeout: 3
    retry:
      count: 3
      delay: 1
    targets:
      - https://example.com/
      - https://google.com/
      - https://httpbin.org/delay/2
      - https://httpbin.org/status/500
      - http://localhost:8080/checks/v1alpha1/latency
      - http://localhost:8081/checks/v1alpha1/latency

Sample output

{
	"data": {
		"https://google.com/": {
			"code": 200,
			"error": null,
			"total": 128
		},
		"https://httpbin.org/delay/2": {
			"code": 200,
			"error": null,
			"total": 2283
		},
		"https://httpbin.org/status/500": {
			"code": 500,
			"error": null,
			"total": 133
		}
	},
	"timestamp": "2023-11-29T18:25:03.071057924+01:00",
	"error": ""
}

Openapi Spec

openapi: 3.0.0
components: {}
info:
    title: Sparrow Metrics API
    description: Serves metrics collected by sparrows checks
    contact:
        name: CaaS Team
        url: https://caas.telekom.de
        email: [email protected]
    version: ""
paths:
    /v1/metrics/latency:
        description: latency
        get:
            tags:
                - Metrics
                - latency
            description: Returns the performance data for check latency
            responses:
                "200":
                    description: Metrics for check latency
                    content:
                        application/json:
                            schema:
                                type: object
                                properties:
                                    data:
                                        type: object
                                        additionalProperties:
                                            has: null
                                            schema:
                                                type: object
                                                properties:
                                                    code:
                                                        type: integer
                                                    error:
                                                        type: string
                                                    total:
                                                        type: integer
                                                        format: int64
                                    error:
                                        type: string
                                    timestamp:
                                        type: string
                                        format: date-time

Tests done

TODO

  • Unit tests
  • Fix timing info is always 0
  • Docs

@niklastreml niklastreml added the feature Introduces a new feature label Nov 24, 2023
@niklastreml niklastreml self-assigned this Nov 24, 2023
pkg/checks/latency.go Outdated Show resolved Hide resolved
@y-eight y-eight mentioned this pull request Nov 27, 2023
@y-eight
Copy link
Contributor

y-eight commented Nov 27, 2023

pls merge main into branch.

hint: I renamed loaderFile to loaderFilePath

pkg/config/loader.go Outdated Show resolved Hide resolved
pkg/config/validate.go Outdated Show resolved Hide resolved
pkg/checks/latency.go Outdated Show resolved Hide resolved
cmd/run.go Outdated Show resolved Hide resolved
@niklastreml niklastreml changed the title Draft: Feat/latency check Feat/latency check Nov 30, 2023
config.yaml Outdated Show resolved Hide resolved
config.yaml Outdated Show resolved Hide resolved
pkg/config/config.go Outdated Show resolved Hide resolved
@niklastreml niklastreml merged commit a611c52 into main Nov 30, 2023
@niklastreml niklastreml deleted the feat/latency-check branch November 30, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants