make grafana optional in linkerd-web (#4319)

Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
This commit is contained in:
Tarun Pothulapati 2020-05-07 16:44:55 +00:00 committed by GitHub
parent 2d2fd3f199
commit 2a95d373c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 6 deletions

View File

@ -110,7 +110,7 @@ const trafficSplitDetailColumns = [
},
];
const columnDefinitions = (resource, showNamespaceColumn, showNameColumn, PrefixedLink, isTcpTable) => {
const columnDefinitions = (resource, showNamespaceColumn, showNameColumn, PrefixedLink, isTcpTable, grafana) => {
const isAuthorityTable = resource === 'authority';
const isTrafficSplitTable = resource === 'trafficsplit';
const isMultiResourceTable = resource === 'multi_resource';
@ -200,7 +200,7 @@ const columnDefinitions = (resource, showNamespaceColumn, showNameColumn, Prefix
columns.splice(1, 0, meshedColumn);
}
if (!isTrafficSplitTable) {
if (!isTrafficSplitTable && grafana !== '') {
columns = columns.concat(grafanaColumn);
}
@ -224,12 +224,12 @@ const preprocessMetrics = metrics => {
return tableData;
};
const MetricsTable = ({ metrics, resource, showNamespaceColumn, showName, title, api, isTcpTable, selectedNamespace }) => {
const MetricsTable = ({ metrics, resource, showNamespaceColumn, showName, title, api, isTcpTable, selectedNamespace, grafana }) => {
const showNsColumn = resource === 'namespace' || selectedNamespace !== '_all' ? false : showNamespaceColumn;
const showNameColumn = resource !== 'trafficsplit' ? true : showName;
let orderBy = 'name';
if (resource === 'trafficsplit' && !showNameColumn) { orderBy = 'leaf'; }
const columns = columnDefinitions(resource, showNsColumn, showNameColumn, api.PrefixedLink, isTcpTable);
const columns = columnDefinitions(resource, showNsColumn, showNameColumn, api.PrefixedLink, isTcpTable, grafana);
const rows = preprocessMetrics(metrics);
return (
<BaseTable
@ -254,6 +254,7 @@ MetricsTable.propTypes = {
showName: PropTypes.bool,
showNamespaceColumn: PropTypes.bool,
title: PropTypes.string,
grafana: PropTypes.string.isRequired,
};
MetricsTable.defaultProps = {

View File

@ -28,7 +28,7 @@ func main() {
addr := cmd.String("addr", ":8084", "address to serve on")
metricsAddr := cmd.String("metrics-addr", ":9994", "address to serve scrapable metrics on")
apiAddr := cmd.String("api-addr", "127.0.0.1:8085", "address of the linkerd-controller-api service")
grafanaAddr := cmd.String("grafana-addr", "127.0.0.1:3000", "address of the linkerd-grafana service")
grafanaAddr := cmd.String("grafana-addr", "", "address of the linkerd-grafana service")
templateDir := cmd.String("template-dir", "templates", "directory to search for template files")
staticDir := cmd.String("static-dir", "app/dist", "directory to search for static files")
reload := cmd.Bool("reload", true, "reloading set to true or false")

View File

@ -27,6 +27,7 @@ type (
uuid string
controllerNamespace string
clusterDomain string
grafana string
grafanaProxy *grafanaProxy
hc healthChecker
statCache *cache.Cache
@ -44,6 +45,7 @@ func (h *handler) handleIndex(w http.ResponseWriter, req *http.Request, p httpro
UUID: h.uuid,
ControllerNamespace: h.controllerNamespace,
PathPrefix: pathPfx,
Grafana: h.grafana,
}
version, err := h.apiClient.Version(req.Context(), &pb.Empty{}) // TODO: remove and call /api/version from web app

View File

@ -52,6 +52,7 @@ type (
Error bool
ErrorMessage string
PathPrefix string
Grafana string
}
healthChecker interface {
@ -114,6 +115,7 @@ func NewServer(
uuid: uuid,
controllerNamespace: controllerNamespace,
clusterDomain: clusterDomain,
grafana: grafanaAddr,
grafanaProxy: newGrafanaProxy(grafanaAddr),
hc: hc,
statCache: cache.New(statExpiration, statCleanupInterval),

View File

@ -3,7 +3,8 @@
data-release-version="{{.Data.ReleaseVersion}}"
data-go-version="{{.Data.GoVersion}}"
data-controller-namespace="{{.ControllerNamespace}}"
data-uuid="{{.UUID}}">
data-uuid="{{.UUID}}"
data-grafana="{{.Grafana}}">
{{ if .Error }}
<p>Failed to call public API: {{ .ErrorMessage }}</p>
{{ end }}