Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana/master' into move-threshold-and…
Browse files Browse the repository at this point in the history
…-mapping-to-field

* grafana/master:
  Elasticsearch: Visualize logs in Explore (grafana#17605)
  Grafana-CLI: Wrapper for `grafana-cli` within RPM/DEB packages and config/homepath are now global flags (grafana#17695)
  Add guidelines for SQL date comparisons (grafana#17732)
  Docs: clarified usage of go get and go mod (grafana#17637)
  Project: Issue triage doc improvement (grafana#17709)
  Improvement: Grafana release process minor improvements (grafana#17661)
  TimePicker: New time picker dropdown & custom range UI (grafana#16811)
  RemoteCache: redis connection string parsing test (grafana#17702)
  Fix link in pkg/README (grafana#17714)
  Dashboard: Use Explore's Prometheus editor in dashboard panel edit (grafana#15364)
  Settings: Fix typo in defaults.ini (grafana#17707)
  Project: Adds a security policy (grafana#17698)
  Project: Adds support resource docs (grafana#17699)
  Document issue triage process (grafana#17669)
  noImplicitAny: slate (grafana#17681)
  config: fix connstr for remote_cache (grafana#17675)
  Explore: Improves performance of Logs element by limiting re-rendering (grafana#17685)
  Docs: Flag serve_from_sub_path as available in 6.3 (grafana#17674)
  @grafana/runtime: expose config and loadPluginCss (grafana#17655)
  noImplicitAny: Fix basic errors (grafana#17668)
  • Loading branch information
ryantxu committed Jun 24, 2019
2 parents e1a15a8 + eecd8d1 commit 8dadad1
Show file tree
Hide file tree
Showing 131 changed files with 2,987 additions and 3,447 deletions.
384 changes: 384 additions & 0 deletions ISSUE_TRIAGE.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions SECURITY.md
@@ -0,0 +1,17 @@
Reporting Security Issues
------------------

If you think you have found a security vulnerability, please send a report to [security@grafana.com](mailto:security@grafana.com). This address can be used for all of Grafana Labs's open source and commercial products (including but not limited to Grafana, Grafana Cloud, Grafana Enterprise, and grafana.com). We can accept only vulnerability reports at this address. We would prefer that you encrypt your message to us; please use our PGP key. The key fingerprint is:

F988 7BEA 027A 049F AE8E 5CAA D125 8932 BE24 C5CA

The key is available from [pgp.mit.edu](https://pgp.mit.edu/pks/lookup?op=get&search=0xF9887BEA027A049FAE8E5CAAD1258932BE24C5CA) by searching for [grafana](https://pgp.mit.edu/pks/lookup?search=grafana&op=index).

Grafana Labs will send you a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.

**Important:** We ask you to not disclose the vulnerability before it have been fixed and announced, unless you have got a response from the Grafana Labs security team that you can do that.

### Security Announcements

We maintain a category on the community site called [Security Announcements](https://community.grafana.com/c/security-announcements),
where we will post a summary, remediation, and mitigation details for any patch containing security fixes. You can also subscribe to email updates to this category if you have a grafana.com account and sign on to the community site or track updates via an [RSS feed](https://community.grafana.com/c/security-announcements.rss).
9 changes: 9 additions & 0 deletions SUPPORT.md
@@ -0,0 +1,9 @@
Need help or support?
------------------

**Please note:**
- Only submit issues for bug reports, feature requests or enhancements.
- Grafana project uses GitHub mainly for tracking bugs and feature requests.
- Asking a question by opening an issue will directly result in issue being closed.

If you require help or support then ask a question and/or find existing questions/answers in the [Grafana community site](https://community.grafana.com/).
53 changes: 35 additions & 18 deletions build.go
Expand Up @@ -43,7 +43,9 @@ var (
workingDir string
includeBuildId bool = true
buildId string = "0"
binaries []string = []string{"grafana-server", "grafana-cli"}
serverBinary string = "grafana-server"
cliBinary string = "grafana-cli"
binaries []string = []string{serverBinary, cliBinary}
isDev bool = false
enterprise bool = false
skipRpmGen bool = false
Expand Down Expand Up @@ -230,6 +232,7 @@ type linuxPackageOptions struct {
packageType string
packageArch string
homeDir string
homeBinDir string
binPath string
serverBinPath string
cliBinPath string
Expand All @@ -240,10 +243,11 @@ type linuxPackageOptions struct {
initdScriptFilePath string
systemdServiceFilePath string

postinstSrc string
initdScriptSrc string
defaultFileSrc string
systemdFileSrc string
postinstSrc string
initdScriptSrc string
defaultFileSrc string
systemdFileSrc string
cliBinaryWrapperSrc string

depends []string
}
Expand All @@ -258,17 +262,19 @@ func createDebPackages() {
packageType: "deb",
packageArch: debPkgArch,
homeDir: "/usr/share/grafana",
homeBinDir: "/usr/share/grafana/bin",
binPath: "/usr/sbin",
configDir: "/etc/grafana",
etcDefaultPath: "/etc/default",
etcDefaultFilePath: "/etc/default/grafana-server",
initdScriptFilePath: "/etc/init.d/grafana-server",
systemdServiceFilePath: "/usr/lib/systemd/system/grafana-server.service",

postinstSrc: "packaging/deb/control/postinst",
initdScriptSrc: "packaging/deb/init.d/grafana-server",
defaultFileSrc: "packaging/deb/default/grafana-server",
systemdFileSrc: "packaging/deb/systemd/grafana-server.service",
postinstSrc: "packaging/deb/control/postinst",
initdScriptSrc: "packaging/deb/init.d/grafana-server",
defaultFileSrc: "packaging/deb/default/grafana-server",
systemdFileSrc: "packaging/deb/systemd/grafana-server.service",
cliBinaryWrapperSrc: "packaging/wrappers/grafana-cli",

depends: []string{"adduser", "libfontconfig1"},
})
Expand All @@ -286,17 +292,19 @@ func createRpmPackages() {
packageType: "rpm",
packageArch: rpmPkgArch,
homeDir: "/usr/share/grafana",
homeBinDir: "/usr/share/grafana/bin",
binPath: "/usr/sbin",
configDir: "/etc/grafana",
etcDefaultPath: "/etc/sysconfig",
etcDefaultFilePath: "/etc/sysconfig/grafana-server",
initdScriptFilePath: "/etc/init.d/grafana-server",
systemdServiceFilePath: "/usr/lib/systemd/system/grafana-server.service",

postinstSrc: "packaging/rpm/control/postinst",
initdScriptSrc: "packaging/rpm/init.d/grafana-server",
defaultFileSrc: "packaging/rpm/sysconfig/grafana-server",
systemdFileSrc: "packaging/rpm/systemd/grafana-server.service",
postinstSrc: "packaging/rpm/control/postinst",
initdScriptSrc: "packaging/rpm/init.d/grafana-server",
defaultFileSrc: "packaging/rpm/sysconfig/grafana-server",
systemdFileSrc: "packaging/rpm/systemd/grafana-server.service",
cliBinaryWrapperSrc: "packaging/wrappers/grafana-cli",

depends: []string{"/sbin/service", "fontconfig", "freetype", "urw-fonts"},
})
Expand All @@ -323,10 +331,12 @@ func createPackage(options linuxPackageOptions) {
runPrint("mkdir", "-p", filepath.Join(packageRoot, "/usr/lib/systemd/system"))
runPrint("mkdir", "-p", filepath.Join(packageRoot, "/usr/sbin"))

// copy binary
for _, binary := range binaries {
runPrint("cp", "-p", filepath.Join(workingDir, "tmp/bin/"+binary), filepath.Join(packageRoot, "/usr/sbin/"+binary))
}
// copy grafana-cli wrapper
runPrint("cp", "-p", options.cliBinaryWrapperSrc, filepath.Join(packageRoot, "/usr/sbin/"+cliBinary))

// copy grafana-server binary
runPrint("cp", "-p", filepath.Join(workingDir, "tmp/bin/"+serverBinary), filepath.Join(packageRoot, "/usr/sbin/"+serverBinary))

// copy init.d script
runPrint("cp", "-p", options.initdScriptSrc, filepath.Join(packageRoot, options.initdScriptFilePath))
// copy environment var file
Expand All @@ -338,6 +348,13 @@ func createPackage(options linuxPackageOptions) {
// remove bin path
runPrint("rm", "-rf", filepath.Join(packageRoot, options.homeDir, "bin"))

// create /bin within home
runPrint("mkdir", "-p", filepath.Join(packageRoot, options.homeBinDir))
// The grafana-cli binary is exposed through a wrapper to ensure a proper
// configuration is in place. To enable that, we need to store the original
// binary in a separate location to avoid conflicts.
runPrint("cp", "-p", filepath.Join(workingDir, "tmp/bin/"+cliBinary), filepath.Join(packageRoot, options.homeBinDir, cliBinary))

args := []string{
"-s", "dir",
"--description", "Grafana",
Expand Down Expand Up @@ -391,7 +408,7 @@ func createPackage(options linuxPackageOptions) {
args = append(args, "--iteration", linuxPackageIteration)
}

// add dependenciesj
// add dependencies
for _, dep := range options.depends {
args = append(args, "--depends", dep)
}
Expand Down
4 changes: 2 additions & 2 deletions conf/defaults.ini
Expand Up @@ -118,7 +118,7 @@ type = database
# database: will use Grafana primary database.
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=0`. Only addr is required.
# memcache: 127.0.0.1:11211
;connstr =
connstr =

#################################### Data proxy ###########################
[dataproxy]
Expand Down Expand Up @@ -394,7 +394,7 @@ enabled = false
config_file = /etc/grafana/ldap.toml
allow_sign_up = true

# LDAP backround sync (Enterprise only)
# LDAP background sync (Enterprise only)
sync_cron = @hourly
active_sync_enabled = false

Expand Down
3 changes: 3 additions & 0 deletions devenv/datasources.yaml
Expand Up @@ -153,6 +153,9 @@ datasources:
interval: Daily
timeField: "@timestamp"
esVersion: 70
timeInterval: "10s"
logMessageField: message
logLevelField: fields.level

- name: gdev-elasticsearch-v7-metricbeat
type: elasticsearch
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/administration/cli.md
Expand Up @@ -37,7 +37,7 @@ If running the command returns this error:
then there are two flags that can be used to set homepath and the config file path.

`grafana-cli admin reset-admin-password --homepath "/usr/share/grafana" newpass`
`grafana-cli --homepath "/usr/share/grafana" admin reset-admin-password newpass`

If you have not lost the admin password then it is better to set in the Grafana UI. If you need to set the password in a script then the [Grafana API](http://docs.grafana.org/http_api/user/#change-password) can be used. Here is an example using curl with basic auth:

Expand Down
1 change: 1 addition & 0 deletions docs/sources/installation/configuration.md
Expand Up @@ -155,6 +155,7 @@ callback URL to be correct).
> case add the subpath to the end of this URL setting.
### serve_from_sub_path
> Available in 6.3 and above
Serve Grafana from subpath specified in `root_url` setting. By
default it is set to `false` for compatibility reasons.
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Expand Up @@ -8,7 +8,8 @@ module.exports = {
"roots": [
"<rootDir>/public/app",
"<rootDir>/public/test",
"<rootDir>/packages"
"<rootDir>/packages",
"<rootDir>/scripts",
],
"testRegex": "(\\.|/)(test)\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -190,8 +190,12 @@
"@babel/polyfill": "7.2.5",
"@torkelo/react-select": "2.4.1",
"@types/angular-route": "1.7.0",
"@types/d3-scale-chromatic": "1.3.1",
"@types/enzyme-adapter-react-16": "1.0.5",
"@types/react-redux": "^7.0.8",
"@types/redux-logger": "3.0.7",
"@types/reselect": "2.2.0",
"@types/slate": "0.44.11",
"angular": "1.6.6",
"angular-bindonce": "0.3.1",
"angular-native-dragdrop": "1.2.2",
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-runtime/package.json
Expand Up @@ -18,6 +18,7 @@
"license": "Apache-2.0",
"dependencies": {},
"devDependencies": {
"@types/systemjs": "^0.20.6",
"awesome-typescript-loader": "^5.2.1",
"lodash": "^4.17.10",
"pretty-format": "^24.5.0",
Expand Down
78 changes: 78 additions & 0 deletions packages/grafana-runtime/src/config.ts
@@ -0,0 +1,78 @@
import extend from 'lodash/extend';
import { GrafanaTheme, getTheme, GrafanaThemeType, PanelPluginMeta, DataSourceInstanceSettings } from '@grafana/ui';

export interface BuildInfo {
version: string;
commit: string;
isEnterprise: boolean;
env: string;
latestVersion: string;
hasUpdate: boolean;
}

export class GrafanaBootConfig {
datasources: { [str: string]: DataSourceInstanceSettings } = {};
panels: { [key: string]: PanelPluginMeta } = {};
appSubUrl = '';
windowTitlePrefix = '';
buildInfo: BuildInfo = {} as BuildInfo;
newPanelTitle = '';
bootData: any;
externalUserMngLinkUrl = '';
externalUserMngLinkName = '';
externalUserMngInfo = '';
allowOrgCreate = false;
disableLoginForm = false;
defaultDatasource = '';
alertingEnabled = false;
alertingErrorOrTimeout = '';
alertingNoDataOrNullValues = '';
authProxyEnabled = false;
exploreEnabled = false;
ldapEnabled = false;
oauth: any;
disableUserSignUp = false;
loginHint: any;
passwordHint: any;
loginError: any;
viewersCanEdit = false;
editorsCanAdmin = false;
disableSanitizeHtml = false;
theme: GrafanaTheme;
pluginsToPreload: string[] = [];

constructor(options: GrafanaBootConfig) {
this.theme = options.bootData.user.lightTheme ? getTheme(GrafanaThemeType.Light) : getTheme(GrafanaThemeType.Dark);

const defaults = {
datasources: {},
windowTitlePrefix: 'Grafana - ',
panels: {},
newPanelTitle: 'Panel Title',
playlist_timespan: '1m',
unsaved_changes_warning: true,
appSubUrl: '',
buildInfo: {
version: 'v1.0',
commit: '1',
env: 'production',
isEnterprise: false,
},
viewersCanEdit: false,
editorsCanAdmin: false,
disableSanitizeHtml: false,
};

extend(this, defaults, options);
}
}

const bootData = (window as any).grafanaBootData || {
settings: {},
user: {},
};

const options = bootData.settings;
options.bootData = bootData;

export const config = new GrafanaBootConfig(options);
2 changes: 2 additions & 0 deletions packages/grafana-runtime/src/index.ts
@@ -1 +1,3 @@
export * from './services';
export * from './config';
export { loadPluginCss } from './utils/plugin';
17 changes: 17 additions & 0 deletions packages/grafana-runtime/src/utils/plugin.ts
@@ -0,0 +1,17 @@
import { config } from '../config';

/* tslint:disable:import-blacklist */
import System from 'systemjs';

export interface PluginCssOptions {
light: string;
dark: string;
}

export function loadPluginCss(options: PluginCssOptions) {
if (config.bootData.user.lightTheme) {
System.import(options.light + '!css');
} else {
System.import(options.dark + '!css');
}
}
20 changes: 12 additions & 8 deletions packages/grafana-ui/src/components/Select/ButtonSelect.tsx
@@ -1,9 +1,9 @@
import React, { PureComponent } from 'react';
import React, { PureComponent, ReactElement } from 'react';
import Select, { SelectOptionItem } from './Select';
import { PopperContent } from '../Tooltip/PopperController';

interface ButtonComponentProps {
label: string | undefined;
label: ReactElement | string | undefined;
className: string | undefined;
iconClass?: string;
}
Expand All @@ -21,7 +21,8 @@ const ButtonComponent = (buttonProps: ButtonComponentProps) => (props: any) => {
<div className="select-button">
{iconClass && <i className={`select-button-icon ${iconClass}`} />}
<span className="select-button-value">{label ? label : ''}</span>
<i className="fa fa-caret-down fa-fw" />
{!props.menuIsOpen && <i className="fa fa-caret-down fa-fw" />}
{props.menuIsOpen && <i className="fa fa-caret-up fa-fw" />}
</div>
</button>
);
Expand All @@ -30,8 +31,8 @@ const ButtonComponent = (buttonProps: ButtonComponentProps) => (props: any) => {
export interface Props<T> {
className: string | undefined;
options: Array<SelectOptionItem<T>>;
value: SelectOptionItem<T>;
label?: string;
value?: SelectOptionItem<T>;
label?: ReactElement | string;
iconClass?: string;
components?: any;
maxMenuHeight?: number;
Expand All @@ -40,6 +41,7 @@ export interface Props<T> {
isMenuOpen?: boolean;
onOpenMenu?: () => void;
onCloseMenu?: () => void;
tabSelectsValue?: boolean;
}

export class ButtonSelect<T> extends PureComponent<Props<T>> {
Expand All @@ -61,6 +63,7 @@ export class ButtonSelect<T> extends PureComponent<Props<T>> {
isMenuOpen,
onOpenMenu,
onCloseMenu,
tabSelectsValue,
} = this.props;
const combinedComponents = {
...components,
Expand All @@ -75,13 +78,14 @@ export class ButtonSelect<T> extends PureComponent<Props<T>> {
options={options}
onChange={this.onChange}
value={value}
isOpen={isMenuOpen}
onOpenMenu={onOpenMenu}
onCloseMenu={onCloseMenu}
maxMenuHeight={maxMenuHeight}
components={combinedComponents}
className="gf-form-select-box-button-select"
tooltipContent={tooltipContent}
isOpen={isMenuOpen}
onOpenMenu={onOpenMenu}
onCloseMenu={onCloseMenu}
tabSelectsValue={tabSelectsValue}
/>
);
}
Expand Down

0 comments on commit 8dadad1

Please sign in to comment.