Skip to content

Commit

Permalink
Merge pull request #138 from krakend/dev-2.6
Browse files Browse the repository at this point in the history
Dev 2.6
  • Loading branch information
alombarte authored Mar 11, 2024
2 parents fec806e + b023b37 commit 9caee45
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/designer.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ angular
}

$rootScope.modules_in_use = [];
service_components = ['documentation/openapi', 'auth/api-keys', 'telemetry/newrelic', 'telemetry/moesif', 'server/virtualhost', 'server/static-filesystem'];
service_components = ['documentation/openapi', 'auth/api-keys', 'telemetry/newrelic', 'telemetry/moesif', 'server/virtualhost', 'server/static-filesystem', 'grpc'];
endpoint_components = ['documentation/openapi', 'websocket', 'modifier/jmespath', 'security/policies', 'modifier/response-body-generator'];
backend_components = ['auth/gcp','auth/ntlm','backend/http/client','backend/soap', 'modifier/jmespath', 'security/policies', 'modifier/body-generator', 'modifier/response-body-generator', 'backend/static-filesystem'];
http_server_plugins = ['ip-filter', 'jwk-aggregator', 'krakend-afero', 'basic-auth', 'geoip', 'redis-ratelimit', 'url-rewrite', 'wildcard'];
Expand Down
25 changes: 21 additions & 4 deletions src/app/forms/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,36 @@ <h3 class="box-title">What is the KrakenD Designer</h3>
</div>
<div class="box-body">
<p>
The KrakenD Designer is an open-source javascript application that helps you configure
the API Gateway in a visual way and get familiar with the main functionalities KrakenD has.
The KrakenD Designer is configuration builder, released as an open-source javascript application. It helps you create and edit
<code>krakend.json</code> files to get started with the API Gateway in a visual way.
</p>
<p>It is a pure static page that <strong>does not send any of your configurations elsewhere nor track its
contents.</strong>
It's hosted online for convenience, but you can also run it locally.
contents.</strong> It's hosted online for convenience, but you can also run it locally.
</p>
<p>Use this page together with a <a href="https://www.krakend.io/docs/developer/hot-reload/">KrakenD Watch</a> image to apply the changes in your local server automatically.</p>
<p>
<a class="btn btn-primary" target="_blank" href="https://www.krakend.io/docs/configuration/designer/"><i class="fa fa-book"></i> Documentation</a>
</p>
</div>
</div>
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">What can I do with KrakenD Designer?</h3>
</div>
<div class="box-body">
<p>
The KrakenD Designer generates a single configuration file. It is meant to become familiar with the JSON file and contains <strong>many number of functionalities</strong>.
</p>
<p>Because the interface might already look overwhelming given the number of features it displays, the most advanced flags and some features are not configurable here. Still, if you import and export files with these hidden attributes, the designer respects them.</p>
<p>The main <strong>limitations</strong> of this tool are:</p>
<ul>
<li>You cannot work with Flexible Configuration (multiple configuration files)</li>
<li>Use non-JSON formats, like YAML or TOML</li>
<li>Administer a production gateway. This is meant to be a development tool.</li>
<li>It does not check the validity of what you type.</li>
</ul>
</div>
</div>
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">Development tools</h3>
Expand Down
4 changes: 2 additions & 2 deletions src/app/forms/logging.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="col-md-6">
<middleware data="service" template="gologging.html" namespace="'telemetry/logging'"></middleware>
<middleware ng-if="service.extra_config['telemetry/logging']" data="service" template="gelf.html" namespace="'telemetry/gelf'"></middleware>
<middleware data="service" template="metrics.html" namespace="'telemetry/metrics'"></middleware>

<opentelemetry data="service"></opentelemetry>
</div>
<div class="col-md-6">
<middleware data="service" template="metrics.html" namespace="'telemetry/metrics'"></middleware>
<opencensus data="service"></opencensus>
<middleware data="service" template="newrelic.html" namespace="'telemetry/newrelic'"></middleware>
</div>
2 changes: 1 addition & 1 deletion src/app/metrics/opencensus.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="box-header with-border">
<h3 class="box-title"><input type="checkbox"
ng-checked="isMiddlewareEnabled()"
ng-click="toggleOpencensusMiddleware()"> Opencensus <small>(Newrelic, Zipkin, InfluxDB, Prometheus, Jaeger, Stackdriver, Datadog, and more)</small>
ng-click="toggleOpencensusMiddleware()"> Opencensus (DEPRECATED)
</h3>
<div class="pull-right" ng-include src="'/src/app/layout/docs.html'" ng-repeat="doc in [{'ee': false, 'url':'/telemetry/opencensus/'}]"></div>
</div>
Expand Down
103 changes: 103 additions & 0 deletions src/app/metrics/opentelemetry.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
angular
.module('KrakenDesigner')
.directive("opentelemetry", function() {
return {
restrict : "E",
templateUrl: '/src/app/metrics/opentelemetry.html',
scope: {
data: '=',
inherit: '='
},
link: function(scope, element, attrs) {

var default_opentelemetry_settings = {
"trace_sample_rate": 0.25,
"metric_reporting_period": 1,
"exporters": {},
"layers": {
"global": {
"disable_metrics": false,
"disable_traces": false,
"disable_propagation": false
},
"proxy": {
"disable_metrics": false,
"disable_traces": false
},
"backend": {
"metrics": {
"disable_stage": false,
"round_trip": false,
"read_payload": false,
"detailed_connection": false,
"static_attributes": []
},
"traces": {
"disable_stage": false,
"round_trip": false,
"read_payload": false,
"detailed_connection": false,
"static_attributes": []
}
}
},

}

var default_exporter_settings = {
"otlp": {
"name": "otlp_exporter",
"host": "otlp.yourprovider.net",
"port": 4317,
"use_http": false,
"disable_metrics": false,
"disable_traces": false
},
"prometheus": {
"name": "prometheus_exporter",
"port": 9090
}
};

var NAMESPACE = 'telemetry/opentelemetry';

// Create extra_config namespace with default data and merge with existing content:
scope.data.extra_config = Object.assign({}, scope.data.extra_config );


// Easier access for the template:
scope.config_namespace = NAMESPACE;


scope.isMiddlewareEnabled = function() {
return !( 'undefined' === typeof scope.data.extra_config[NAMESPACE] );
}

scope.toggleOpenTelemetryMiddleware = function () {
if ( scope.isMiddlewareEnabled() ) {
delete scope.data.extra_config[NAMESPACE];
} else {
scope.data.extra_config[NAMESPACE] = default_opentelemetry_settings;
}
}

scope.addExporter = function (exporter) {
if ( 'undefined' === typeof scope.data.extra_config[NAMESPACE].exporters ) {
scope.data.extra_config[NAMESPACE].exporters = {};
}

if ( 'undefined' === typeof scope.data.extra_config[NAMESPACE].exporters[exporter] ) {
scope.data.extra_config[NAMESPACE].exporters[exporter] = [];
}
scope.data.extra_config[NAMESPACE].exporters[exporter].push(default_exporter_settings[exporter]);
}

scope.deleteExporter = function(index,exporter) {
scope.data.extra_config[NAMESPACE].exporters[exporter].splice(index, 1);
if ( 0 == scope.data.extra_config[NAMESPACE].exporters[exporter].length ) {
delete scope.data.extra_config[NAMESPACE].exporters[exporter];
}
}
}
}
});
123 changes: 123 additions & 0 deletions src/app/metrics/opentelemetry.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<div class="box box-info box-solid">
<div class="box-header with-border">
<h3 class="box-title"><input type="checkbox" ng-checked="isMiddlewareEnabled()"
ng-click="toggleOpenTelemetryMiddleware()"> OpenTelemetry <small>(Newrelic, Datadog, Elastic APM, Grafana,
Prometheus, Jaeger, and more)</small>
</h3>
<div class="pull-right" ng-include src="'/src/app/layout/docs.html'"
ng-repeat="doc in [{'ee': false, 'url':'/telemetry/opentelemetry/'}]"></div>
</div>
<div class="box-body">
<p ng-if="!isMiddlewareEnabled()">The OpenTelemetry <em>middleware</em> provides several integrations to export
tracing and metrics to different third party systems.</p>
<div ng-if="isMiddlewareEnabled()">
<div class="row">
<div class="col-md-6">
<label class="control-label">Tracing sample rate</label>
<div class="input-group">
<input type="number" class="form-control" ng-model="data.extra_config[config_namespace].trace_sample_rate"
placeholder="0.75">
</div>
<div class="help-block">
Percentage of traces you want to sample (decimal between 0 and 1).
</div>
</div>
<div class="col-md-6">
<label class="control-label">Reporting period</label>
<div class="input-group">
<input type="number" class="form-control" ng-model="data.extra_config[config_namespace].metric_reporting_period"
placeholder="1">
<div class="input-group-addon">seconds</div>
</div>
<div class="help-block">
Time between sent reports to the backend
</div>
</div>
</div>
<h4>Exporters</h4>
<div class="row">
<div class="col-md-6">
<button class="btn btn-primary" ng-click="addExporter('prometheus')">
<i class="fa fa-plus"></i>
New Prometheus Exporter
</button>
<span class="help-block">KrakenD will start listening on a port that Prometheus can use to scrap
metrics</span>
</div>
<div class="col-md-6">
<button class="btn btn-primary" ng-click="addExporter('otlp')">
<i class="fa fa-plus"></i>
New OTLP Exporter
</button>
<span class="help-block">Integrate with many third parties using OpenTelemetry Protocol (OTLP)</span>
</div>
</div>
<div class="">
<div class="box" ng-repeat="(pi,p) in data.extra_config[config_namespace].exporters['otlp'] track by $index">
<div class="box-header with-border">
<h3 class="box-title">Exporter <code>{{p.name}}</code></h3>
<div class="pull-right ng-scope">
<span class="badge">OTLP</span>
<a ng-click="deleteExporter(pi,'otlp')" class="badge badge-info badge-remove"><i
class="fa fa-trash"></i></a>
</div>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-6">
<label class="control-label">Name</label>
<input type="text" class="form-control" ng-model="p.name" placeholder="your_exporter_name">
<span class="help-block">A unique name to identify this exporter.</span>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="data.extra_config[config_namespace].exporters.otlp.use_http">
<strong>Use HTTP</strong>
</label>
<span class="help-block">Check when the collector uses HTTP instead of gRPC</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label class="control-label">Hostname</label>
<input type="text" class="form-control" ng-model="p.host" placeholder="e.g. localhost">
<span class="help-block">The host where you want to push the data</span>
</div>
<div class="col-md-6">
<label class="control-label">Port</label>
<input type="number" class="form-control" ng-model="p.port" placeholder="e.g: 9090">
<span class="help-block">The port where the collector listens</span>
</div>
</div>
</div>
</div>
<div class="box"
ng-repeat="(pi,p) in data.extra_config[config_namespace].exporters['prometheus'] track by $index">
<div class="box-header with-border">
<h3 class="box-title">Exporter <code>{{p.name}}</code></h3>
<div class="pull-right ng-scope">
<span class="badge badge-info">Prometheus</span>
<a ng-click="deleteExporter(pi,'prometheus')" class="badge badge-info badge-remove"><i
class="fa fa-trash"></i></a>
</div>
</div>
<div class="box-body">
<div class="col-md-6">
<label class="control-label">Name</label>
<input type="text" class="form-control" ng-model="p.name" placeholder="your_exporter_name">
<span class="help-block">A unique name to identify this exporter.</span>
</div>
<div class="col-md-6">
<label class="control-label">Port</label>
<input type="number" class="form-control" ng-model="p.port" placeholder="e.g: 9092">
<span class="help-block">The port in KrakenD where Prometheus will connect to</span>
</div>
</div>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion src/app/middlewares/newrelic.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="box box-info box-solid">
<div class="box-header with-border">
<h3 class="box-title"><input type="checkbox" ng-checked="isMiddlewareEnabled()"
ng-click="toggleMiddleware()"> NewRelic</h3>
ng-click="toggleMiddleware()"> NewRelic (Native SDK)</h3>
<div class="pull-right" ng-include src="'/src/app/layout/docs.html'"
ng-repeat="doc in [{'ee': true, 'url':'/telemetry/newrelic/'}]"></div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/app/service/http_client_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ <h4>Connections</h4>
</div>
<div class="col-md-2">
<div class="checkbox">
<label for="service.allow_insecure_connections">
<label for="service.client_tls.allow_insecure_connections">
<input type="checkbox"
id="service.allow_insecure_connections"
name="service.allow_insecure_connections"
ng-model="service.allow_insecure_connections"
id="service.client_tls.allow_insecure_connections"
name="service.client_tls.allow_insecure_connections"
ng-model="service.client_tls.allow_insecure_connections"
placeholder="0s"
type="text">
<strong>Allow insecure connections</strong>
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import './app/services/input_validator.service.js';
import './app/middlewares/middleware.directive.js';
import './app/middlewares/apikey.directive.js';
import './app/plugins/plugin.directive.js';
import './app/metrics/opentelemetry.directive.js';
import './app/metrics/opencensus.directive.js';
import './app/endpoint/json-formatter.directive.js';
import './app/dropBox.directive.js';
Expand Down
5 changes: 5 additions & 0 deletions src/scss/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ a.badge.badge-inverse:hover {
background-color: #0071CE;
}

.badge.badge-info {
background-color: #dfdfdf;
color: black;
}

.nav-tabs-custom .nav-tabs li a {
font-weight: bold;
font-size: 15px;
Expand Down

0 comments on commit 9caee45

Please sign in to comment.