-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #207 metrics ingestion endpoint v0.2
- Loading branch information
1 parent
d94f130
commit d9b1a5d
Showing
4 changed files
with
68 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,16 @@ Ptah.sh takes the pain out of deployment by easing common tasks used in many pro | |
- Load balancing of an incoming traffic and SSL auto-provisioning via Caddy Server. | ||
- And many more features. | ||
|
||
## Components | ||
|
||
Ptah.sh is a collection of several interdependent services: | ||
|
||
- [Ptah.sh Server](https://github.com/ptah-sh/ptah-server) - the core of the platform, responsible for managing the infrastructure, scaling, and load balancing. | ||
- [Ptah.sh Agent](https://github.com/ptah-sh/ptah-agent) - the component installed on the target machine, responsible for running the containers and services. | ||
- [Ptah.sh Caddy](https://github.com/ptah-sh/ptah-caddy) - the component installed on the target machine, responsible for running the Caddy Server and providing metrics to the Ptah.sh Server. | ||
- [Ptah.sh GitHub Action](https://github.com/ptah-sh/deploy-action) - the component responsible for deploying the application to the target machine. | ||
- [Ptah.sh Website](https://github.com/ptah-sh/ptah-sh.github.io) - the website of the Ptah.sh platform available at [ptah.sh](https://ptah.sh), containing the documentation, 1-Click Apps templates and the public-facing information. | ||
|
||
## Ptah.sh Sponsors | ||
|
||
We would like to extend our thanks to the following sponsors for funding Ptah.sh development. If you are interested in becoming a sponsor, please send an e-mail to Bohdan Shulha via [[email protected]](mailto:[email protected]). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Services; | ||
|
||
use Illuminate\Support\Facades\Http; | ||
|
||
// Multitenancy for single node: https://docs.victoriametrics.com/single-server-victoriametrics/#prometheus-querying-api-enhancements | ||
class Metrics | ||
{ | ||
public static function importPrometheusMetrics($swarmId, $nodeId, $metrics) | ||
{ | ||
$query = ''; | ||
$query .= '?extra_label=swarm_id='.$swarmId; | ||
$query .= '&extra_label=node_id='.$nodeId; | ||
|
||
return Http::withBody(implode("\n", $metrics), 'text/plain')->post(config('database.victoriametrics.url').'/api/v1/import/prometheus'.$query); | ||
} | ||
|
||
public static function getMetrics($query, $nodeIds) | ||
{ | ||
return Http::asForm()->post(config('database.victoriametrics.url').'/api/v1/query', [ | ||
'query' => $query, | ||
'step' => '30s', | ||
'extra_filters' => '{node_id=~"'.implode('|', $nodeIds).'"}', | ||
'latency_offset' => '5s', | ||
])->json(); | ||
} | ||
|
||
public static function getMetricsRange($query, $nodeIds) | ||
{ | ||
return Http::asForm()->post(config('database.victoriametrics.url').'/api/v1/query_range', [ | ||
'query' => $query, | ||
'start' => now()->subMinutes(5)->subSeconds(30)->getTimestampMs() / 1000, | ||
'end' => now()->subSeconds(30)->getTimestampMs() / 1000, | ||
'step' => '5s', | ||
'extra_filters' => '{node_id=~"'.implode('|', $nodeIds).'"}', | ||
'latency_offset' => '5s', | ||
])->json(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,4 +170,7 @@ | |
|
||
], | ||
|
||
'victoriametrics' => [ | ||
'url' => rtrim(env('VICTORIAMETRICS_URL', 'http://localhost:8428'), '/'), | ||
], | ||
]; |