gcpservice

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: BSD-3-Clause Imports: 25 Imported by: 0

README

GCP

Installation

  1. Create a directory for the install. Suggested:: mkdir -p /opt/circonus/cloud-agent
  2. Download the latest release
  3. Unpack the release in the directory created in first step
  4. In this directory, create a config folder. Suggested: mkdir /opt/circonus/cloud-agent/etc/gcp.d
  5. Auto-create a service specific configuration template in the desired format (yaml, toml, or json). Suggested: sbin/circonus-cloud-agentd --enable-gcp --gcp-example-conf=yaml > etc/gcp.d/gcp-config.yaml
    • Note, the id in the template is defaulted to the filename. This should be changed to a name that will be unique across all cloud-agents used in Circonus
    • Follow configuration instructions to finish config settings.
  6. Setup as a system service or run in foreground ensuring that --enable-gcp is specified

Options

$  sbin/circonus-cloud-agentd -h
The Circonus Cloud Agent collects metrics from cloud infrastructures and fowards them to Circonus.

Usage:
  circonus-cloud-agent [flags]

Flags:
      --gcp-conf-dir string         GCP configuration directory (default "/opt/circonus/cloud-agent/etc/gcp.d")
      --gcp-example-conf string     Show GCP config (json|toml|yaml) and exit
  -c, --config string               config file (default: circonus-cloud-agent.yaml|.json|.toml)
  -d, --debug                       [ENV: CCA_DEBUG] Enable debug messages
      --enable-gcp                  Enable GCP metric collection client
  -h, --help                        help for circonus-cloud-agent
      --log-level string            [ENV: CCA_LOG_LEVEL] Log level [(panic|fatal|error|warn|info|debug|disabled)] (default "info")
      --log-pretty                  [ENV: CCA_LOG_PRETTY] Output formatted/colored log lines [ignored on windows]
  -V, --version                     Show version and exit

Configuration

Google
  1. Find project to monitor in GCP UI
  2. Add service account to project
    • Set service account name, e.g. 'circonus-cloud-agent'
    • Add description
    • Click create
    • Add roles: project>viewer, monitoring>monitoring viewer, compute engine>compute viewer
    • Create key, type JSON (note where the key is downloaded)
      • Place the JSON file downloaded in GCP setup somewhere and ensure that the user running circonus-cloud-agentd will be able to read the file (e.g. nobody on linux when run as a systemd service).
      • Ensure that the configuration file setting gcp.credentials_file is set to the full filespec of where the service account JSON file was placed.
  3. The following APIs must be enabled for the project
    • Cloud Resource Manager API - role project>viewer is used to obtain the project meta data: ensure it is an active project, project name is used to create check bundle, project labels are added as a base set of stream tags along with project id
    • Stackdriver Monitoring API - role monitoring>monitoring viewer is used to retrieve available metrics and metric data
    • Compute Engine API - role compute engine>compute viewer is used to obtain a list of instances, obtain state/status of an instance, name, labels (for stream tags), etc.
  4. Add these to the gcp section of the configuration file.
Circonus
  1. Use Circonus UI to create or identify an API Token to use
  2. Add the key to the config file under the circonus section
Example configuration

Minimum configuration:

---
id: ...
gcp:
  credentials_file: ...
circonus:
  key: ...

Documentation

Index

Constants

View Source
const (
	// KeyEnabled toggles whether the GCP module is active or not.
	KeyEnabled = "gcp.enabled"
	// DefaultEnabled defines the default setting.
	DefaultEnabled = false

	// KeyConfDir defines the gcp configuration directory.
	KeyConfDir = "gcp.conf_dir"

	// KeyConfExample shows an example configuration.
	KeyConfExample = "gcp.config_example"
)

Variables

View Source
var (
	// DefaultConfDir is the default location of gcp configuration files.
	DefaultConfDir = path.Join(defaults.EtcPath, "gcp.d")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ID       string                 `json:"id" toml:"id" yaml:"id"`                   // unique id for this service client instance, no spaces (ties several things together, short and immutable - logging, check search/create, tags, etc.)
	Circonus circonus.ServiceConfig `json:"circonus" toml:"circonus" yaml:"circonus"` // REQUIRED circonus config: api credentials, check, broker, etc.
	Tags     circonus.Tags          `json:"tags" toml:"tags" yaml:"tags"`             // global tags, added to all metrics
	GCP      GCPConfig              `json:"gcp" toml:"gcp" yaml:"gcp"`                // REQUIRED gcp configuration
}

Config defines the options for a gcp service instance.

type GCPConfig

type GCPConfig struct {
	Collectors      []collectors.GCPCollector `json:"services" toml:"services" yaml:"services"`                         // which services to collectc metrics for in this region
	CredentialsFile string                    `json:"credentials_file" toml:"credentials_file" yaml:"credentials_file"` // REQUIRED gcp service account credentials file (if it does not begin with filepath.Separator, the default etc path - relative to where circonus-cloud-agentd is running - will be used, allowing relative paths)

	Interval int `json:"collect_interval" toml:"collect_interval" yaml:"collect_interval"` // DEFAULT: 5 - How often to collect metrics.(minutes >= 5)
	// contains filtered or unexported fields
}

GCPConfig holds the gcp specific configuration options.

type GCPService

type GCPService struct {
	// contains filtered or unexported fields
}

GCPService defines the GCP cloud service client.

func New

func New(ctx context.Context) (*GCPService, error)

New returns a GCP metric collector service.

func (*GCPService) Enabled

func (svc *GCPService) Enabled() bool

Enabled indicates whether the GCP service is enabled.

func (*GCPService) Scan

func (svc *GCPService) Scan() error

Scan checks the service config directory for configurations and loads them.

func (*GCPService) Start

func (svc *GCPService) Start() error

Start begins collecting metrics from GCP.

type Instance

type Instance struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Instance defines a specific gcp service instance for collecting metrics.

func (*Instance) Start

func (inst *Instance) Start() error

Start runs the instance based on the configured interval.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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