ajout heimdall
This commit is contained in:
77
heimdall/config/www/SupportedApps/Jaeger/Jaeger.php
Executable file
77
heimdall/config/www/SupportedApps/Jaeger/Jaeger.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?php namespace App\SupportedApps\Jaeger;
|
||||
|
||||
class Jaeger extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
|
||||
public $config;
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
private function tracesUrl() {
|
||||
$service = $this->config->service;
|
||||
$operation = $this->config->operation;
|
||||
$tags = $this->config->tags;
|
||||
$lookback = $this->config->lookback;
|
||||
$minDuration = $this->config->minDuration;
|
||||
$maxDuration = $this->config->maxDuration;
|
||||
$limit = $this->config->limit;
|
||||
|
||||
$endpoint = 'api/traces?service='.urlencode($service);
|
||||
if (!empty($operation)) $endpoint .= '&operation='.urlencode($operation);
|
||||
if (!empty($tags)) $endpoint .= '&tags='. urlencode($tags);
|
||||
if (!empty($lookback)) {
|
||||
$lookbackFormatted = str_replace('d', ' days', str_replace('h', ' hours', $lookback));
|
||||
$timestampForOffset = time();
|
||||
$offset = $timestampForOffset - strtotime('-'.$lookbackFormatted, $timestampForOffset);
|
||||
|
||||
$timestamp = microtime(true);
|
||||
$end = sprintf('%0.0f', $timestamp * 1000000);
|
||||
$start = sprintf('%0.0f', ($timestamp - $offset) * 1000000);
|
||||
$endpoint .= '&lookback='.urlencode($lookback);
|
||||
$endpoint .= '&start='.$start;
|
||||
$endpoint .= '&end='.$end;
|
||||
}
|
||||
if (!empty($minDuration)) $endpoint .= '&minDuration='.urlencode($minDuration);
|
||||
if (!empty($maxDuration)) $endpoint .= '&maxDuration='.urlencode($maxDuration);
|
||||
if (!empty($limit)) $endpoint .= '&limit='.urlencode($limit);
|
||||
return $this->url($endpoint);
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$test = parent::appTest($this->tracesUrl());
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = 'inactive';
|
||||
$res = parent::execute($this->tracesUrl());
|
||||
$details = json_decode($res->getBody());
|
||||
|
||||
$data = [];
|
||||
|
||||
if($details) {
|
||||
$status = 'active';
|
||||
$data['traces'] = count($details->data);
|
||||
$data['avg_duration'] = 0;
|
||||
if ($data['traces'] > 0) {
|
||||
$durations = array_map(function($dataItem) {
|
||||
$max = 0;
|
||||
foreach ($dataItem->spans as $spanItem) {
|
||||
$max = max($max, $spanItem->duration);
|
||||
}
|
||||
return $max;
|
||||
}, $details->data);
|
||||
$data['avg_duration'] = round(array_sum($durations)/$data['traces']/1000, 1);
|
||||
}
|
||||
}
|
||||
return parent::getLiveStats($status, $data);
|
||||
|
||||
}
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url).$endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/Jaeger/app.json
Executable file
10
heimdall/config/www/SupportedApps/Jaeger/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "917883dc82d936304725edacb6bf11e5cf537be6",
|
||||
"name": "Jaeger",
|
||||
"website": "https://www.jaegertracing.io/",
|
||||
"license": "Apache License 2.0",
|
||||
"description": "Jaeger is a distributed tracing platform, which can be used for monitoring microservices-based distributed systems.",
|
||||
"enhanced": true,
|
||||
"tile_background": "light",
|
||||
"icon": "jaeger.png"
|
||||
}
|
||||
42
heimdall/config/www/SupportedApps/Jaeger/config.blade.php
Executable file
42
heimdall/config/www/SupportedApps/Jaeger/config.blade.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ strtoupper(__('app.url')) }}</label>
|
||||
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Service</label>
|
||||
{!! Form::text('config[service]', (isset($item) ? $item->getconfig()->service : 'jaeger-query'), array('placeholder' => 'Service, e.g. jaeger-query', 'data-config' => 'service', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Operation</label>
|
||||
{!! Form::text('config[operation]', (isset($item) ? $item->getconfig()->operation : null), array('placeholder' => 'Operation, e.g. /api/traces', 'data-config' => 'operation', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.tags') }}</label>
|
||||
{!! Form::text('config[tags]', (isset($item) ? $item->getconfig()->tags : null), array('placeholder' => __('app.apps.tags'), 'data-config' => 'tags', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Lookback</label>
|
||||
{!! Form::select('config[lookback]', array('1h' => 'Last Hour', '2h' => 'Last 2 Hours', '3h' => 'Last 3 Hours', '6h' => 'Last 6 Hours', '12h' => 'Last 12 Hours', '24h' => 'Last 24 Hours', '2d' => 'Last 2 Days'), (isset($item) ? $item->getconfig()->lookback : null), array('data-config' => 'lookback', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Limit</label>
|
||||
{!! Form::text('config[limit]', (isset($item) ? $item->getconfig()->limit : 100), array('placeholder' => 'Limit results', 'data-config' => 'limit', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>Min Duration</label>
|
||||
{!! Form::text('config[minDuration]', (isset($item) ? $item->getconfig()->minDuration : null), array('placeholder' => 'e.g. 1.2s, 100ms, 500us', 'data-config' => 'minDuration', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>MaxDuration</label>
|
||||
{!! Form::text('config[maxDuration]', (isset($item) ? $item->getconfig()->maxDuration : null), array('placeholder' => 'e.g. 1.2s, 100ms, 500us', 'data-config' => 'maxDuration', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
BIN
heimdall/config/www/SupportedApps/Jaeger/jaeger.png
Executable file
BIN
heimdall/config/www/SupportedApps/Jaeger/jaeger.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
10
heimdall/config/www/SupportedApps/Jaeger/livestats.blade.php
Executable file
10
heimdall/config/www/SupportedApps/Jaeger/livestats.blade.php
Executable file
@@ -0,0 +1,10 @@
|
||||
<ul class="livestats">
|
||||
<li>
|
||||
<span class="title">Traces</span>
|
||||
<strong>{!! $traces !!}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Duration</span>
|
||||
<strong>{!! $avg_duration !!} ms</strong>
|
||||
</li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user