collector

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DataUnits = map[string]string{"C": "metric", "F": "imperial", "K": "internal"}
)

Functions

This section is empty.

Types

type ApiResponse added in v0.0.12

type ApiResponse interface {
	*OneCallCurrentData | *PollutionData
}

type Gauge added in v0.0.12

type Gauge[T ApiResponse] struct {
	// contains filtered or unexported fields
}

func (*Gauge[T]) Desc added in v0.0.12

func (g *Gauge[T]) Desc() *prometheus.Desc

func (*Gauge[T]) FromResponse added in v0.0.12

func (g *Gauge[T]) FromResponse(data any) prometheus.Metric

type Location added in v0.0.5

type Location struct {
	Location  string
	Latitude  float64
	Longitude float64
}

type Metric added in v0.0.12

type Metric interface {
	Desc() *prometheus.Desc
	FromResponse(any) prometheus.Metric
}

func OneCallGauges added in v0.0.12

func OneCallGauges(location string) []Metric

func PollutionGauges added in v0.0.12

func PollutionGauges(location string) []Metric

type OneCallCurrentData added in v0.0.12

type OneCallCurrentData struct {
	Dt         int       `json:"dt"`
	Sunrise    int       `json:"sunrise"`
	Sunset     int       `json:"sunset"`
	Temp       float64   `json:"temp"`
	FeelsLike  float64   `json:"feels_like"`
	Pressure   int       `json:"pressure"`
	Humidity   int       `json:"humidity"`
	DewPoint   float64   `json:"dew_point"`
	Clouds     int       `json:"clouds"`
	UVI        float64   `json:"uvi"`
	Visibility int       `json:"visibility"`
	WindSpeed  float64   `json:"wind_speed"`
	WindGust   float64   `json:"wind_gust,omitempty"`
	WindDeg    float64   `json:"wind_deg"`
	Rain       Rain      `json:"rain,omitempty"`
	Snow       Snow      `json:"snow,omitempty"`
	Weather    []Weather `json:"weather"`
}

func CurrentByCoordinates added in v0.0.12

func CurrentByCoordinates(loc Location, client *http.Client, settings *Settings) (*OneCallCurrentData, error)

type OneCallData added in v0.0.12

type OneCallData struct {
	Latitude       float64            `json:"lat"`
	Longitude      float64            `json:"lon"`
	Timezone       string             `json:"timezone"`
	TimezoneOffset int                `json:"timezone_offset"`
	Current        OneCallCurrentData `json:"current,omitempty"`
}

OneCallData the API should be called with exclude=minutely,hourly,daily,alerts

type OpenweatherCollector

type OpenweatherCollector struct {
	*Settings
	Cache     *ttlcache.Cache
	Locations []Location
	// contains filtered or unexported fields
}

func NewOpenweatherCollector

func NewOpenweatherCollector(settings *Settings, locationsStr string, cache *ttlcache.Cache) *OpenweatherCollector

NewOpenweatherCollector You must create a constructor for your collector that initializes every descriptor and returns a pointer to the collector

func (*OpenweatherCollector) Collect

func (collector *OpenweatherCollector) Collect(ch chan<- prometheus.Metric)

Collect implements required collect function for all prometheus collectors

func (*OpenweatherCollector) Describe

func (collector *OpenweatherCollector) Describe(ch chan<- *prometheus.Desc)

Describe Each and every collector must implement the Describe function. It essentially writes all descriptors to the prometheus desc channel.

type Pollution added in v0.0.12

type Pollution struct {
	Location struct {
		Longitude float64 `json:"lon"`
		Latitude  float64 `json:"lat"`
	} `json:"coord"`
	List []PollutionData `json:"list"`
}

type PollutionData added in v0.0.12

type PollutionData struct {
	Dt   int `json:"dt"`
	Main struct {
		Aqi float64 `json:"aqi"`
	} `json:"main"`
	Components struct {
		Co   float64 `json:"co"`
		No   float64 `json:"no"`
		No2  float64 `json:"no2"`
		O3   float64 `json:"o3"`
		So2  float64 `json:"so2"`
		Pm25 float64 `json:"pm2_5"`
		Pm10 float64 `json:"pm10"`
		Nh3  float64 `json:"nh3"`
	} `json:"components"`
}

func PollutionByCoordinates added in v0.0.12

func PollutionByCoordinates(loc Location, client *http.Client, settings *Settings) (*PollutionData, error)

type Rain added in v0.0.12

type Rain struct {
	OneH float64 `json:"1h,omitempty"`
}

type Settings added in v0.0.12

type Settings struct {
	ApiKey      string
	DegreesUnit string
	Language    string
	EnablePol   bool
}

type Snow added in v0.0.12

type Snow struct {
	OneH float64 `json:"1h,omitempty"`
}

type Weather added in v0.0.12

type Weather struct {
	ID          int    `json:"id"`
	Main        string `json:"main"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
}

Weather https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2

type Wind added in v0.0.12

type Wind struct {
	Speed float64 `json:"speed"`
	Deg   float64 `json:"deg"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL