mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
offline license utilization reporting (#25844)
Nomad Enterprise users operating in air-gapped or otherwise secured environments don't want to send license reporting metrics directly from their servers. Implement manual/offline reporting by periodically recording usage metrics snapshots in the state store, and providing an API and CLI by which cluster administrators can download the snapshot for review and out-of-band transmission to HashiCorp. This is the CE portion of the work required for implemention in the Enterprise product. Nomad CE does not perform utilization reporting. Ref: https://github.com/hashicorp/nomad-enterprise/pull/2673 Ref: https://hashicorp.atlassian.net/browse/NMD-68 Ref: https://go.hashi.co/rfc/nmd-210
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -475,3 +476,28 @@ func (op *Operator) UpgradeCheckVaultWorkloadIdentity(q *QueryOptions) (*VaultWo
|
||||
}
|
||||
return &resp, qm, nil
|
||||
}
|
||||
|
||||
type OperatorUtilizationOptions struct {
|
||||
TodayOnly bool
|
||||
}
|
||||
|
||||
type OperatorUtilizationSnapshotResponse struct {
|
||||
// Bundle is the JSON serialized utilization reporting bundle.
|
||||
Bundle []byte
|
||||
WriteMeta
|
||||
}
|
||||
|
||||
// Utilization retrieves a utilization reporting bundle (Nomad Enterprise only).
|
||||
func (op *Operator) Utilization(opts *OperatorUtilizationOptions, w *WriteOptions) (*OperatorUtilizationSnapshotResponse, *WriteMeta, error) {
|
||||
resp := &OperatorUtilizationSnapshotResponse{}
|
||||
v := url.Values{}
|
||||
if opts.TodayOnly {
|
||||
v.Add("today", "true")
|
||||
}
|
||||
|
||||
wm, err := op.c.post("/v1/operator/utilization?"+v.Encode(), nil, resp, w)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return resp, wm, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user