watchfor 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/exe/watchfor +6 -1
- data/lib/watchfor/client.rb +23 -3
- data/lib/watchfor/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24445c1731afb7a7acc92e91e6e96ddae0c59d837111c2addcd5fed3c0d3727d
|
|
4
|
+
data.tar.gz: f38989c598bca87881af765542036fe1b8fb310c7c8c75a64487e4ef22bfa5a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e9b130b18719ef0a4a08ba2df4c17b245884222e00cd140a6164a10bc8026098d99cf3db469bfea2af0b44cb98d286ddf5231d62967a2a95d1df75974a7d316
|
|
7
|
+
data.tar.gz: bb479462a71d46c19220fbd488c628f69bfce49b07cc6daa5430b6fc1ff3f58cf56598b2fcb3f601f086aeb60e406cc415530880cb206486ae337d95fd5e4b95
|
data/README.md
CHANGED
|
@@ -48,6 +48,11 @@ run = wf.playwright.test_run(script: script, target: "https://shop.example.com")
|
|
|
48
48
|
wf.playwright.get_test_run(run["id"]) # status: queued | running | done | error
|
|
49
49
|
wf.variables.put("LOGIN_PASSWORD", value: password, secret: true)
|
|
50
50
|
|
|
51
|
+
# The same org secrets in HTTP/API/MCP checks: {{NAME}} in auth, a header or the body
|
|
52
|
+
wf.variables.put("API_TOKEN", value: token, secret: true)
|
|
53
|
+
wf.monitors.update(api_monitor_id, { config: { requestHeaders: [
|
|
54
|
+
{ key: "Authorization", value: "Bearer {{API_TOKEN}}" }] } })
|
|
55
|
+
|
|
51
56
|
# Older checks: pass next_cursor back as cursor (keep the same hours/success)
|
|
52
57
|
page = wf.monitors.checks(mon["id"], hours: 24, limit: 100)
|
|
53
58
|
wf.monitors.checks(mon["id"], hours: 24, limit: 100, cursor: page["next_cursor"]) if page["next_cursor"]
|
|
@@ -90,6 +95,14 @@ Namespaces: `wf.monitors`, `wf.alert_rules`, `wf.incidents`,
|
|
|
90
95
|
`wf.incident_stats(period)`, `wf.notifications`, `wf.activity`. Errors raise
|
|
91
96
|
`Watchfor::Error` with `#status`, `#code`, `#message`.
|
|
92
97
|
|
|
98
|
+
## Prometheus metrics (Pro plan and above)
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
text = wf.metrics(tag: "production") # Prometheus text format
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Usually you point Prometheus at `https://watchfor.io/api/v1/metrics` directly; this is for scripts and one-off checks. See https://watchfor.io/docs/api/prometheus.
|
|
105
|
+
|
|
93
106
|
## CLI
|
|
94
107
|
|
|
95
108
|
```bash
|
data/exe/watchfor
CHANGED
|
@@ -36,8 +36,13 @@ begin
|
|
|
36
36
|
cursor = args.include?("--cursor") ? args[args.index("--cursor") + 1] : nil
|
|
37
37
|
wf.monitors.checks(monitor_id, cursor: cursor)
|
|
38
38
|
when "report" then wf.report(period: args.include?("--period") ? args[args.index("--period") + 1] : nil)
|
|
39
|
+
when "metrics"
|
|
40
|
+
tag = args.include?("--tag") ? args[args.index("--tag") + 1] : nil
|
|
41
|
+
type = args.include?("--type") ? args[args.index("--type") + 1] : nil
|
|
42
|
+
print wf.metrics(tag: tag, type: type)
|
|
43
|
+
exit 0
|
|
39
44
|
else
|
|
40
|
-
warn "Usage: watchfor [summary|plan|monitors|locations|monitor-types|incidents|checks <monitor_id> [--cursor c]|report [--period 7d|30d]]"
|
|
45
|
+
warn "Usage: watchfor [summary|plan|monitors|locations|monitor-types|incidents|checks <monitor_id> [--cursor c]|report [--period 7d|30d]|metrics [--tag t] [--type t]]"
|
|
41
46
|
exit 2
|
|
42
47
|
end
|
|
43
48
|
puts JSON.pretty_generate(result)
|
data/lib/watchfor/client.rb
CHANGED
|
@@ -51,7 +51,7 @@ module Watchfor
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Core request. +query+ and +body+ are optional hashes.
|
|
54
|
-
def request(method, path, query: nil, body: nil, idempotency_key: nil)
|
|
54
|
+
def request(method, path, query: nil, body: nil, idempotency_key: nil, text: false)
|
|
55
55
|
uri = URI("#{@base_url}#{path}")
|
|
56
56
|
unless query.nil? || query.empty?
|
|
57
57
|
cleaned = query.reject { |_, v| v.nil? || v == "" }
|
|
@@ -65,7 +65,7 @@ module Watchfor
|
|
|
65
65
|
}.fetch(method)
|
|
66
66
|
req = klass.new(uri)
|
|
67
67
|
req["Authorization"] = "Bearer #{@api_key}"
|
|
68
|
-
req["Accept"] = "application/json"
|
|
68
|
+
req["Accept"] = text ? "text/plain, application/json" : "application/json"
|
|
69
69
|
req["User-Agent"] = "watchfor-ruby/#{Watchfor::VERSION}"
|
|
70
70
|
req["Idempotency-Key"] = idempotency_key if idempotency_key
|
|
71
71
|
unless body.nil?
|
|
@@ -80,6 +80,8 @@ module Watchfor
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
raw = res.body.to_s
|
|
83
|
+
return raw if text && res.code.to_i.between?(200, 299)
|
|
84
|
+
|
|
83
85
|
parsed = raw.empty? ? nil : (JSON.parse(raw) rescue nil)
|
|
84
86
|
unless res.code.to_i.between?(200, 299)
|
|
85
87
|
err = parsed.is_a?(Hash) ? (parsed["error"] || {}) : {}
|
|
@@ -92,6 +94,14 @@ module Watchfor
|
|
|
92
94
|
# Top-level reads
|
|
93
95
|
def me = request("GET", "/me")
|
|
94
96
|
def summary = request("GET", "/summary")
|
|
97
|
+
|
|
98
|
+
# The organization in Prometheus text format (Pro plan and above):
|
|
99
|
+
# status, uptime, response times, expiry, heartbeats, hosts. Cached 60 s.
|
|
100
|
+
def metrics(tag: nil, type: nil, monitor_id: nil, include_hosts: nil)
|
|
101
|
+
query = { tag: tag, type: type, monitor_id: monitor_id,
|
|
102
|
+
include_hosts: include_hosts.nil? ? nil : include_hosts.to_s }
|
|
103
|
+
request("GET", "/metrics", query: query, text: true)
|
|
104
|
+
end
|
|
95
105
|
def plan = request("GET", "/plan")
|
|
96
106
|
def incident_stats(period = nil) = request("GET", "/incidents/stats", query: { period: period })
|
|
97
107
|
|
|
@@ -123,7 +133,16 @@ module Watchfor
|
|
|
123
133
|
def list(**query) = @c.request("GET", "/monitors", query: query)
|
|
124
134
|
# The monitor plus available_metrics (alert metrics valid for its type).
|
|
125
135
|
def get(id) = @c.request("GET", "/monitors/#{id}")
|
|
136
|
+
# Credentials (catalog fields marked secret: mailbox/SMTP/FTP passwords,
|
|
137
|
+
# SSH keys, HTTP/API/MCP auth passwords, bearer tokens and credential
|
|
138
|
+
# header values) are write-only: stored encrypted, returned as
|
|
139
|
+
# "[redacted]". {{NAME}} in an auth field, header or body uses an org
|
|
140
|
+
# variable or secret.
|
|
126
141
|
def create(body, idempotency_key: nil) = @c.request("POST", "/monitors", body: body, idempotency_key: idempotency_key)
|
|
142
|
+
# config is merged (omitted keys kept, nil removes). A "[redacted]"
|
|
143
|
+
# credential is kept when omitted or sent back; changing the server,
|
|
144
|
+
# port, TLS mode or login it is used with (HTTP: the URL's host, port
|
|
145
|
+
# or scheme) needs it again (else 400).
|
|
127
146
|
def update(id, body) = @c.request("PATCH", "/monitors/#{id}", body: body)
|
|
128
147
|
def delete(id) = @c.request("DELETE", "/monitors/#{id}")
|
|
129
148
|
def pause(id) = @c.request("POST", "/monitors/#{id}/pause")
|
|
@@ -168,7 +187,8 @@ module Watchfor
|
|
|
168
187
|
def get_test_run(id) = @c.request("GET", "/playwright/test-runs/#{id}")
|
|
169
188
|
end
|
|
170
189
|
|
|
171
|
-
# Org variables and secrets (process.env.NAME
|
|
190
|
+
# Org variables and secrets (process.env.NAME in browser checks, {{NAME}}
|
|
191
|
+
# in HTTP/API/MCP checks); secrets are write-only.
|
|
172
192
|
class Variables < Namespace
|
|
173
193
|
def list = @c.request("GET", "/variables")
|
|
174
194
|
def put(name, value: nil, secret: false)
|
data/lib/watchfor/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: watchfor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- WatchFor
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Zero-dependency Ruby client for the WatchFor REST API (monitors, alert
|
|
14
13
|
rules, incidents, maintenance windows) plus a `watchfor` CLI.
|
|
@@ -33,7 +32,6 @@ metadata:
|
|
|
33
32
|
documentation_uri: https://watchfor.io/docs/api
|
|
34
33
|
changelog_uri: https://watchfor.io/changelog
|
|
35
34
|
rubygems_mfa_required: 'true'
|
|
36
|
-
post_install_message:
|
|
37
35
|
rdoc_options: []
|
|
38
36
|
require_paths:
|
|
39
37
|
- lib
|
|
@@ -48,8 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
48
46
|
- !ruby/object:Gem::Version
|
|
49
47
|
version: '0'
|
|
50
48
|
requirements: []
|
|
51
|
-
rubygems_version: 3.
|
|
52
|
-
signing_key:
|
|
49
|
+
rubygems_version: 3.6.7
|
|
53
50
|
specification_version: 4
|
|
54
51
|
summary: Official Ruby SDK + CLI for WatchFor — uptime & infrastructure monitoring.
|
|
55
52
|
test_files: []
|