Configure your accounts¶
Getting started runs Tapyr against a simulator. This guide takes you to your own account: the credentials, the account, its jobs, an output, then the checks before the first request. The example uses Cisco Meraki; every provider works the same way, and its README gives what differs.
1. Pick a provider package¶
tapyr provider list lists the packages Tapyr knows, and Providers has them all with their validation status. tapyr provider show <name> describes one: its secrets and params with what they are, its templates with their interval and metrics, its limits with their sources; tapyr provider show <name> --example prints its example configuration, ready to copy. The README of a package says more:
- what it collects, template by template, and what each template costs in requests;
- the credentials it needs and the permissions to give them (read-only is always enough: Tapyr never writes);
- its params (a regional base URL, an organization ID...), and its limits with their sources.
For Meraki, that is tapyr provider show meraki-dashboard and the meraki-dashboard README: an API key of a read-only administrator, and nothing else.
2. Keep the credentials out of the configuration¶
A secret is never written in a configuration file: it is a reference to an environment variable ({ env: NAME }) or to a file ({ file: /path }), read at start and on every reload. Configuration files can then live in Git.
export TAPYR_MERAKI_API_KEY='...' # or a file readable by Tapyr only
With systemd, put the variables in the environment file of the unit (systemd); on Kubernetes, in a Secret (Kubernetes). The logs, the status API and the web UI never show a secret: Tapyr redacts their values everywhere.
3. Write the configuration¶
One file or several, in one directory: Tapyr reads every .yaml and .yml file of the paths given to --config.
apiVersion: tapyr/v1alpha1
kind: Account
metadata: { name: campus }
spec:
provider: meraki-dashboard
secrets:
apiKey: { env: TAPYR_MERAKI_API_KEY }
labels: { site: campus }
# The per-organization rate is shared with the other applications of the
# organizations: leave them half of it.
budget: { share: 0.5, scaleRates: true }
---
apiVersion: tapyr/v1alpha1
kind: Job
metadata: { name: device-availabilities }
spec:
account: campus
template: meraki-device-availabilities
priority: critical
---
apiVersion: tapyr/v1alpha1
kind: Job
metadata: { name: wireless-clients }
spec: { account: campus, template: meraki-wireless-client-counts }
---
apiVersion: tapyr/v1alpha1
kind: Output
metadata: { name: prometheus }
spec: { type: prometheus }
---
apiVersion: tapyr/v1alpha1
kind: Settings
metadata: { name: settings }
spec:
state: { path: ./data/tapyr.db }
- The account names the provider, its secrets and its params. Its labels are added to every sample. An account with several regional or physical endpoints declares them as
targets(Concepts). - The jobs each use a template of the package, at its default interval unless you set
interval. Discovery is implicit: the jobs above need the list of organizations, and Tapyr runs it for them. Theprioritydecides who slows down first when a quota is short (low,normal,high); acriticaljob is never slowed down. - The output serves the samples on
/metricsfor Prometheus to scrape. Outputs covers remote write and OTLP, and how to send an output less. - The settings are optional. The state store keeps what Tapyr already spent of the quotas across restarts: put it on persistent storage. In a container, also set
server: { listen: "0.0.0.0:9790" }.
The configuration reference has every field. Editors check the files as you type with the JSON Schemas (tapyr schema).
4. Check before the first request¶
tapyr validate --config ./config --check-secrets
tapyr plan --config ./config
validate reports every error with its file, line and column, and what to change: the closest name for a typo, the description of a missing param, where to align a line. --check-secrets also checks that every secret is set. plan projects what the jobs will spend of every quota and tells whether it fits; when it does not, it says which job to slow down or which priority to lower. Both run without calling the provider, so a CI can run them on every change of the configuration.
5. Run it¶
tapyr run --config ./config
The first log line gives the addresses of the web UI, /metrics and the status API. The first runs are spread over the first tenth of their interval, then discovery fans out (Getting started shows it). Change the configuration and send SIGHUP to reload it without a restart: an invalid configuration is rejected, and the previous one keeps running.
When something does not work, Troubleshooting goes from the symptom to the cause; the web UI says the same on the page of the job, with a link to the right section.