Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Unified web console. #6923

Merged
merged 32 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
172d160
Adding new web console.
vogievetsky Jan 26, 2019
9b5e04e
fixed css
lorem--ipsum Jan 28, 2019
436abbd
fix form height
vogievetsky Jan 28, 2019
6ec7817
fix typo
vogievetsky Jan 28, 2019
6f01b79
do import custom react-table css
vogievetsky Jan 28, 2019
d72979e
added repo field so npm does not complain
vogievetsky Jan 28, 2019
0f56a26
ask travis for node 10
vogievetsky Jan 28, 2019
44b718c
move indexing-service/src/main/resources/indexer_static into web-console
vogievetsky Jan 28, 2019
2179192
fix resource names and paths
jihoonson Jan 29, 2019
05e03fe
add licenses
jihoonson Jan 29, 2019
f613aab
fix exclude file
jihoonson Jan 29, 2019
be4e173
add licenses to misc files and tidy up
vogievetsky Jan 29, 2019
ee01390
remove rebase marker
vogievetsky Jan 29, 2019
4cdc8e3
fix link
vogievetsky Jan 29, 2019
aae5c00
updated env variable name
Jan 29, 2019
0c46198
tidy up licenses and surface errors
vogievetsky Jan 29, 2019
d767849
cleanup
vogievetsky Jan 29, 2019
a735d21
Merge branch 'master' of github.com:druid-io/druid into console
jihoonson Jan 30, 2019
e26225d
remove unused code, fix missing await
vogievetsky Jan 30, 2019
240fbbc
TeamCity does not like the name aux
vogievetsky Jan 30, 2019
a49965f
add more links to tasks view
vogievetsky Jan 30, 2019
5a3f640
rm pages
vogievetsky Jan 30, 2019
9c0a5ab
update gitignore
vogievetsky Jan 30, 2019
5357701
update readme to be accurate
vogievetsky Jan 30, 2019
f3a2925
make clean script
vogievetsky Jan 30, 2019
40c2f3e
removed old console dependancy
vogievetsky Jan 30, 2019
2917422
update Jetty routes
vogievetsky Jan 30, 2019
177eddb
add a comment for welcome files for coordinator
jihoonson Jan 31, 2019
9b9a3e7
do not show inital notifaction for now
vogievetsky Jan 31, 2019
7c16de2
renamed overlord console back to console.html
vogievetsky Jan 31, 2019
bf0564d
fix coordinator console
jihoonson Jan 31, 2019
ba84dd4
rename coordinator-console.html to index.html
jihoonson Jan 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ sudo: false
dist: trusty
group: deprecated-2017Q4

language: node_js
node_js:
- "10"

jdk:
- oraclejdk8

Expand Down
72 changes: 0 additions & 72 deletions indexing-service/src/main/resources/indexer_static/console.html

This file was deleted.

10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<module>aws-common</module>
<module>extendedset</module>
<module>hll</module>
<module>web-console</module>
<!-- Core extensions -->
<module>extensions-core/avro-extensions</module>
<module>extensions-core/datasketches</module>
Expand Down Expand Up @@ -1279,6 +1280,15 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<nodeVersion>v10.13.0</nodeVersion>
<npmVersion>6.4.1</npmVersion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
4 changes: 2 additions & 2 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.druid</groupId>
<groupId>org.apache.druid</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

<artifactId>druid-console</artifactId>
<version>0.0.4</version>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.druid</groupId>
Expand Down
Binary file not shown.
9 changes: 4 additions & 5 deletions services/src/main/java/org/apache/druid/cli/CliOverlord.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;

import java.util.List;
Expand All @@ -130,6 +131,7 @@ public class CliOverlord extends ServerRunnable

protected static List<String> UNSECURED_PATHS = ImmutableList.of(
"/",
"/favicon.png",
"/console.html",
"/old-console/*",
"/images/*",
Expand Down Expand Up @@ -353,17 +355,14 @@ public void initialize(Server server, Injector injector)
final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
root.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
root.setInitParameter("org.eclipse.jetty.servlet.Default.redirectWelcome", "true");
root.setWelcomeFiles(new String[]{"index.html", "console.html"});
root.setWelcomeFiles(new String[]{"console.html"});

ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);

root.addServlet(holderPwd, "/");
root.setBaseResource(
new ResourceCollection(
new String[]{
TaskMaster.class.getClassLoader().getResource("static").toExternalForm(),
TaskMaster.class.getClassLoader().getResource("indexer_static").toExternalForm()
}
Resource.newClassPathResource("org/apache/druid/console")
)
);

Expand Down
4 changes: 1 addition & 3 deletions services/src/main/java/org/apache/druid/cli/CliRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public void configure(Binder binder)

binder.bind(TieredBrokerHostSelector.class).in(ManageLifecycle.class);
binder.bind(QueryHostFinder.class).in(LazySingleton.class);
binder.bind(new TypeLiteral<List<TieredBrokerSelectorStrategy>>()
{
})
binder.bind(new TypeLiteral<List<TieredBrokerSelectorStrategy>>() {})
.toProvider(TieredBrokerSelectorStrategiesProvider.class)
.in(LazySingleton.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.inject.Key;
import com.google.inject.servlet.GuiceFilter;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.server.coordinator.DruidCoordinatorConfig;
import org.apache.druid.server.http.OverlordProxyServlet;
import org.apache.druid.server.http.RedirectFilter;
Expand All @@ -45,7 +44,6 @@
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;

import java.util.List;
import java.util.Properties;
Expand All @@ -55,32 +53,26 @@
class CoordinatorJettyServerInitializer implements JettyServerInitializer
{
private static List<String> UNSECURED_PATHS = Lists.newArrayList(
"/favicon.ico",
"/css/*",
"/druid.js",
"/druid.css",
"/favicon.png",
"/pages/*",
"/fonts/*",
"/coordinator-console/*",
"/index.html",
"/old-console/*",
"/coordinator/false",
"/overlord/false",
"/status/health",
"/druid/coordinator/v1/isLeader"
);

private static Logger log = new Logger(CoordinatorJettyServerInitializer.class);

private final DruidCoordinatorConfig config;
private final boolean beOverlord;
private final AuthConfig authConfig;
private final ServerConfig serverConfig;

@Inject
CoordinatorJettyServerInitializer(DruidCoordinatorConfig config, Properties properties, AuthConfig authConfig, ServerConfig serverConfig)
CoordinatorJettyServerInitializer(DruidCoordinatorConfig config, Properties properties, ServerConfig serverConfig)
{
this.config = config;
this.beOverlord = CliCoordinator.isOverlord(properties);
this.authConfig = authConfig;
this.serverConfig = serverConfig;
}

Expand All @@ -89,25 +81,15 @@ public void initialize(Server server, Injector injector)
{
final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
root.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
root.setInitParameter("org.eclipse.jetty.servlet.Default.redirectWelcome", "true");
// index.html is the welcome file for old-console
root.setWelcomeFiles(new String[]{"index.html"});

ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);

root.addServlet(holderPwd, "/");
if (config.getConsoleStatic() == null) {
ResourceCollection staticResources;
if (beOverlord) {
staticResources = new ResourceCollection(
Resource.newClassPathResource("io/druid/console"),
Resource.newClassPathResource("static"),
Resource.newClassPathResource("indexer_static")
);
} else {
staticResources = new ResourceCollection(
Resource.newClassPathResource("io/druid/console"),
Resource.newClassPathResource("static")
);
}
root.setBaseResource(staticResources);
root.setBaseResource(Resource.newClassPathResource("org/apache/druid/console"));
} else {
// used for console development
root.setResourceBase(config.getConsoleStatic());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.druid.cli;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Injector;
Expand All @@ -46,6 +47,7 @@
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource;

import javax.servlet.Servlet;
import java.util.List;
Expand All @@ -60,6 +62,18 @@ public class RouterJettyServerInitializer implements JettyServerInitializer
DruidAvaticaHandler.AVATICA_PATH
);

protected static List<String> UNSECURED_PATHS_FOR_UI = ImmutableList.of(
"/",
"/coordinator-console/*",
"/public/*",
"/old-console/*",
"/pages/*",
"/unified-console.html",
"/favicon.png",
"/console.html",
"/index.html"
);

private final DruidHttpClientConfig routerHttpClientConfig;
private final DruidHttpClientConfig globalHttpClientConfig;
private final ManagementProxyConfig managementProxyConfig;
Expand Down Expand Up @@ -92,6 +106,10 @@ public RouterJettyServerInitializer(
public void initialize(Server server, Injector injector)
{
final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
root.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
root.setInitParameter("org.eclipse.jetty.servlet.Default.redirectWelcome", "true");
// index.html is the welcome file for old-console
root.setWelcomeFiles(new String[]{"unified-console.html", "index.html"});

root.addServlet(new ServletHolder(new DefaultServlet()), "/*");

Expand All @@ -107,13 +125,20 @@ public void initialize(Server server, Injector injector)
root.addServlet(managementForwardingServletHolder, "/proxy/*");
}

if (managementProxyConfig.isEnabled()) {
root.setBaseResource(Resource.newClassPathResource("org/apache/druid/console"));
}

final ObjectMapper jsonMapper = injector.getInstance(Key.get(ObjectMapper.class, Json.class));
final AuthenticatorMapper authenticatorMapper = injector.getInstance(AuthenticatorMapper.class);

AuthenticationUtils.addSecuritySanityCheckFilter(root, jsonMapper);

// perform no-op authorization for these resources
AuthenticationUtils.addNoopAuthorizationFilters(root, UNSECURED_PATHS);
if (managementProxyConfig.isEnabled()) {
AuthenticationUtils.addNoopAuthorizationFilters(root, UNSECURED_PATHS_FOR_UI);
}
AuthenticationUtils.addNoopAuthorizationFilters(root, authConfig.getUnsecuredPaths());

final List<Authenticator> authenticators = authenticatorMapper.getAuthenticatorChain();
Expand Down
13 changes: 13 additions & 0 deletions web-console/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node/
node_modules/
resources/
public/
lib/*.css

coordinator-console/
pages/
index.html

.tscache
tscommand-*.tmp.txt

65 changes: 65 additions & 0 deletions web-console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

# Apache Druid web console

This is the unified Druid web console that servers as a data management layer for Druid.

## How to watch and run for development

1. You need to be withing the `web-console` directory
2. Install the modules with `npm install`
3. Run `npm start` will start in development mode and will proxy druid requests to `localhost:8888`

**Note:** you can provide an environment variable to proxy to a different Druid host like so: `druid_host=1.2.3.4:8888 npm start`


## Description of the directory structure

A lot of the directory structure was created to preserve the existing console structure as much as possible.

As part of this repo:

- `console.html` - Entry file for the overlord console
- `lib/` - A place where some overrides to the react-table stylus files live, this is outside of the normal SCSS build system.
- `old-console/` - Files for the overlord console
- `public/` - The compiled destination of the file powering this console
- `script/` - Some helper bash scripts for running this console
- `src/` - This directory (together with `lib`) constitutes all the source code for this console

Generated/copied dynamically

- `index.html` - Entry file for the coordinator console
- `pages/` - The files for the older coordinator console
- `coordinator-console/` - Files for the coordinator console


## List of non SQL data reading APIs used

```
GET /status
GET /druid/indexer/v1/supervisor?full
GET /druid/indexer/v1/workers
GET /druid/coordinator/v1/loadqueue?simple
GET /druid/coordinator/v1/config
GET /druid/coordinator/v1/metadata/datasources?includeDisabled
GET /druid/coordinator/v1/rules
GET /druid/coordinator/v1/config/compaction
GET /druid/coordinator/v1/tiers
```
Loading