Skip to content

Commit

Permalink
machine_has_static_ip metric
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-cheperis committed Aug 26, 2024
1 parent edab66e commit 9db3991
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ vastai_machine_is_verified{machine_id="3100"} 1
vastai_machine_is_dc{machine_id="2100"} 0
vastai_machine_is_dc{machine_id="3100"} 0
# HELP vastai_machine_has_static_ip Does machine have static IP (1) or not (0)
vastai_machine_has_static_ip{machine_id="2100"} 1
vastai_machine_has_static_ip{machine_id="3100"} 1
# HELP vastai_machine_ondemand_price_per_gpu_dollars Machine on-demand price per GPU/hour
vastai_machine_ondemand_price_per_gpu_dollars{machine_id="2100"} 0.7
vastai_machine_ondemand_price_per_gpu_dollars{machine_id="3100"} 0.7
Expand Down
2 changes: 2 additions & 0 deletions src/vastai_api_offers_decoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type VastAiOffer struct {
PricePerGpu int // in cents
Verified bool
Datacenter bool
StaticIp bool
Vram float64
DlperfPerGpuChunk float64
DlperfPerGpuWhole float64
Expand Down Expand Up @@ -62,6 +63,7 @@ func (offers VastAiRawOffers) decode() VastAiOffers {
PricePerGpu: offer.pricePerGpu(),
Verified: offer.verified(),
Datacenter: offer.datacenter(),
StaticIp: offer.staticIp(),
}
vram, _ := offer["gpu_ram"].(float64)
dlperf, _ := offer["dlperf"].(float64)
Expand Down
4 changes: 4 additions & 0 deletions src/vastai_api_offers_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ func (offer VastAiRawOffer) datacenter() bool {
return int(offer["hosting_type"].(float64)) > 0
}

func (offer VastAiRawOffer) staticIp() bool {
return offer["static_ip"].(bool)
}

func (offer VastAiRawOffer) rentable() bool {
return offer["rentable"].(bool)
}
Expand Down
9 changes: 9 additions & 0 deletions src/vastai_collector_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type VastAiAccountCollector struct {
machine_info *prometheus.GaugeVec
machine_is_verified *prometheus.GaugeVec
machine_is_dc *prometheus.GaugeVec
machine_has_static_ip *prometheus.GaugeVec
machine_is_listed *prometheus.GaugeVec
machine_is_online *prometheus.GaugeVec
machine_reliability *prometheus.GaugeVec
Expand Down Expand Up @@ -94,6 +95,11 @@ func newVastAiAccountCollector() *VastAiAccountCollector {
Name: "machine_is_dc",
Help: "Is machine marked as datacenter (1) or not (0)",
}, []string{"machine_id"}),
machine_has_static_ip: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "machine_has_static_ip",
Help: "Does machine have static IP (1) or not (0)",
}, []string{"machine_id"}),
machine_is_listed: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "machine_is_listed",
Expand Down Expand Up @@ -200,6 +206,7 @@ func (e *VastAiAccountCollector) Describe(ch chan<- *prometheus.Desc) {
e.machine_info.Describe(ch)
e.machine_is_verified.Describe(ch)
e.machine_is_dc.Describe(ch)
e.machine_has_static_ip.Describe(ch)
e.machine_is_listed.Describe(ch)
e.machine_is_online.Describe(ch)
e.machine_reliability.Describe(ch)
Expand Down Expand Up @@ -232,6 +239,7 @@ func (e *VastAiAccountCollector) Collect(ch chan<- prometheus.Metric) {
e.machine_info.Collect(ch)
e.machine_is_verified.Collect(ch)
e.machine_is_dc.Collect(ch)
e.machine_has_static_ip.Collect(ch)
e.machine_is_listed.Collect(ch)
e.machine_is_online.Collect(ch)
e.machine_reliability.Collect(ch)
Expand Down Expand Up @@ -330,6 +338,7 @@ func (e *VastAiAccountCollector) UpdateMachinesAndInstances(info VastAiApiResult
e.machine_per_gpu_dlperf_score_whole.With(labels).Set(offer.DlperfPerGpuWhole)
}
e.machine_is_dc.With(labels).Set(boolToFloat(offer.Datacenter))
e.machine_has_static_ip.With(labels).Set(boolToFloat((offer.StaticIp)))
break
}
}
Expand Down

0 comments on commit 9db3991

Please sign in to comment.