一、安装与配置
1、启动服务
下载完成后在CMD里面执行
java -jar metabase.jar
2、访问
默认端口是3000
http://localhost:3000
3、配置数据库
登录管理员,选择数据库,可以看到【添加数据库】
QQ截图20190816133640.png
选择需要增加的数据库
模式是H2数据库
如果在下拉选择列表中没有你要的数据库类型,比如oracle数据库
需要将oracle的jdbc驱动复制到metabase\plugins目录中,重启metabase服务即可
4、数据分析逻辑关系
相当于一个数据分析报告,里面包含各种图表、报表等信息
QQ截图20190816134630.png
分享(发布)仪表盘
二、嵌入应用
1、java Web应用的嵌入
需要引用spring-security-jwt-1.0.7.RELEASE.jar
实现一个servlet用来实现地址的组装
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.security.jwt.Jwt;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.security.jwt.crypto.sign.MacSigner;
public class MetabaseServlet extends HttpServlet {
private final String METABASE_SITE_URL = "http://10.1.1.8:3000";
private final String METABASE_SECRET_KEY = "826479736e3de3c885cef4e8461d970d4f28f2c5268059d92c378f48c2e29734";
/**
*
*/
private static final long serialVersionUID = -1763642712983141002L;
Logger logger = LogManager.getLogger(MetabaseServlet.class);
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String resource_dashboard=req.getParameter("resource_dashboard");
String titled=req.getParameter("titled");
if(null==titled) {
titled="false";
}
String theme=req.getParameter("theme");
if(null==theme) {
theme="";
}
String bordered=req.getParameter("bordered");
if(null==bordered) {
bordered="true";
}
logger.info("resource_dashboard = "+resource_dashboard);
Jwt token = JwtHelper.encode("{\"resource\": {\"dashboard\": "+resource_dashboard+"}, \"params\": {}}", new MacSigner(METABASE_SECRET_KEY));
String url = METABASE_SITE_URL + "/embed/dashboard/" + token.getEncoded() + "#theme="+theme+"&bordered="+bordered+"&titled="+titled;
resp.setContentType("text/javascript; charset=UTF-8");
logger.info("get json data is \n"+url);
resp.getWriter().write(url);
}
}
其他细节
a、全文件搜索【EmbedFrame-footer】
嵌入的的页面中不在显示页脚的内容
将js文件【metabase\frontend_client\app\dist\app-embed.bundle.js】中创建页脚的代码删掉
网友评论