Giter VIP home page Giter VIP logo

checkly-operator's Introduction

Checkly Go SDK

Contributor Covenant Tests GoDoc Go Report Card GitHub go.mod Go version GitHub tag (latest by date)

This project is a Go SDK for Checkly monitoring service. It allows you to handle your checks, check groups, snippets, environments variables and everything you can do with our REST API.

Installation

To use the client library with your Checkly account, you will need an API Key for the account. Go to the Account Settings: API Keys page and click 'Create API Key'.

Make sure your project is using Go Modules (it will have a go.mod file in its root if it already is):

$ go mod init

Then, add the reference of checkly-go-sdk in a Go program using import:

import checkly "github.com/checkly/checkly-go-sdk"

Run any of the normal go commands (build/install/test) and the Go toolchain will resolve and fetch the checkly-go-sdk module automatically.

Alternatively, you can also explicitly go get the package into a project:

$ go get -u github.com/checkly/checkly-go-sdk

Getting Started

Create a new checkly Client by calling checkly.NewClient() (you will need to set your Checkly API Key and Account ID)

baseUrl := "https://api.checklyhq.com"
apiKey := os.Getenv("CHECKLY_API_KEY")
accountId := os.Getenv("CHECKLY_ACCOUNT_ID")

client := checkly.NewClient(
	baseUrl,
	apiKey,
	nil, //custom http client, defaults to http.DefaultClient
	nil, //io.Writer to output debug messages
)

client.SetAccountId(accountId)

Note: if you don't have an API key, you can create one at here

Create your first checks

Once you have a client, you can create a check. See here how to create your first API & Browser checks.

apiCheck := checkly.Check{
	Name:                 "My API Check",
	Type:                 checkly.TypeAPI,
	Frequency:            5,
	Activated:            true,
	Locations: []string{
		"eu-west-1",
		"ap-northeast-2",
	},
	Tags: []string{ "production" },
	Request: checkly.Request{
		Method: http.MethodGet,
		URL:    "https://api.checklyhq.com/v1",
	},
}

browserCheck := checkly.Check{
	Name:          "My Browser Check",
	Type:          checkly.TypeBrowser,
	Frequency:     5,
	Activated:     true,
	Locations:     []string{"eu-west-1"},
	Script: `const assert = require("chai").assert;
	const puppeteer = require("puppeteer");

	const browser = await puppeteer.launch();
	const page = await browser.newPage();
	await page.goto("https://example.com");
	const title = await page.title();

	assert.equal(title, "Example Site");
	await browser.close();`,
}

ctx := context.WithTimeout(context.Background(), time.Second * 5)
client.CreateCheck(ctx, apiCheck)
client.CreateCheck(ctx, browserCheck)

A complete example program! You can see an example program which creates a Checkly check in the demo folder.

Questions

For questions and support please open a new discussion. The issue list of this repo is exclusively for bug reports and feature/docs requests.

Issues

Please make sure to respect issue requirements and choose the proper issue template when opening an issue. Issues not conforming to the guidelines may be closed.

Contribution

Please make sure to read the Contributing Guide before making a pull request.

License

MIT

checkly-operator's People

Contributors

akosveres avatar alexb-img avatar vbotnari-img avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

checkly-operator's Issues

Checks created are not functioning

Any check created through the operator doesn't work on checklyhq.com. Reason is unclear.

The checks are created, they are valid, but they always fail. Same checks created manually succeed.

Checkly-operator version: v1.2.3

Feature Request: Webhook Alert Channels

Hey,

we're experimenting with the Checkly Operator and hit a limitation.
We're using GitLab Alerts and would like to use the Webhook Alert Channel via this operator.
Currently only OpsGenie and E-Mail is supported.

Would be great if this could be added, for the moment we're implementing a workaround via Checkly CLI/API.

Groups have to be in the same namespace as apiChecks

We are tying each ApiCheck to a Group, unfortunately at the moment each group has to be inside the same namespace as the ApiCheck, we can not reference groups across namespaces.

In case you are using multiple namespaces for your applications and you have an ingress in all of them, you can not create one group for all, but you need to create a group / namespace.

I'm leaving this issue here to make sure this is documented and hopefully in the future a solution is found.

Failed resource creation is not clear on status

As seen in the youtube video with Stefan, we found that creating an API check that actually fails to be created, it is never clear from a kubectl get <resource-type> <resource-name> that it failed.

Automatic tags from labels causes errors in prometheus integration

Currently we're taking all the labels from the existing ApiCheck or Group resources, any automatic labels from other services will be automatically added as tags, this works as intended.

Checklyhq.com has a prometheus integration, this takes the tags on a check and makes it into a metric label.

At IMG Arena we had a restore procedure from a backup and this created additional labels on the ApiCheck resources, which created the tags on the checklyhq.com API Check as seen below:

image

The prometheus integration broke and we were unable to scrape the checklyhq prometheus endpoint as we received an error (do not have the error anymore unfortunately, will try to reproduce).

Removing the tags from the checklyhq.com api check fixed the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.