Merge branch 'master' of github.com:grafana/grafana
Conflicts: examples/nginx-app/package.json examples/nginx-app/plugin.json
This commit is contained in:
+2
-3
@@ -167,11 +167,10 @@ func Register(r *macaron.Macaron) {
|
||||
r.Put("/:id", bind(m.UpdateDataSourceCommand{}), UpdateDataSource)
|
||||
r.Delete("/:id", DeleteDataSource)
|
||||
r.Get("/:id", wrap(GetDataSourceById))
|
||||
r.Get("/name/:name", wrap(GetDataSourceByName))
|
||||
}, reqOrgAdmin)
|
||||
|
||||
r.Group("/datasources/name/:name", func() {
|
||||
r.Get("/", wrap(GetDataSourceByName))
|
||||
}, reqOrgAdmin)
|
||||
r.Get("/datasources/id/:name", wrap(GetDataSourceIdByName), reqSignedIn)
|
||||
|
||||
r.Group("/plugins", func() {
|
||||
r.Get("/", wrap(GetPluginList))
|
||||
|
||||
@@ -55,8 +55,10 @@ func init() {
|
||||
"S3BytesWritten", "S3BytesRead", "HDFSUtilization", "HDFSBytesRead", "HDFSBytesWritten", "MissingBlocks", "CorruptBlocks", "TotalLoad", "MemoryTotalMB", "MemoryReservedMB", "MemoryAvailableMB", "MemoryAllocatedMB", "PendingDeletionBlocks", "UnderReplicatedBlocks", "DfsPendingReplicationBlocks", "CapacityRemainingGB",
|
||||
"HbaseBackupFailed", "MostRecentBackupDuration", "TimeSinceLastSuccessfulBackup"},
|
||||
"AWS/ES": {"ClusterStatus.green", "ClusterStatus.yellow", "ClusterStatus.red", "Nodes", "SearchableDocuments", "DeletedDocuments", "CPUUtilization", "FreeStorageSpace", "JVMMemoryPressure", "AutomatedSnapshotFailure", "MasterCPUUtilization", "MasterFreeStorageSpace", "MasterJVMMemoryPressure", "ReadLatency", "WriteLatency", "ReadThroughput", "WriteThroughput", "DiskQueueLength", "ReadIOPS", "WriteIOPS"},
|
||||
"AWS/Events": {"Invocations", "FailedInvocations", "TriggeredRules", "MatchedEvents", "ThrottledRules"},
|
||||
"AWS/Kinesis": {"PutRecord.Bytes", "PutRecord.Latency", "PutRecord.Success", "PutRecords.Bytes", "PutRecords.Latency", "PutRecords.Records", "PutRecords.Success", "IncomingBytes", "IncomingRecords", "GetRecords.Bytes", "GetRecords.IteratorAgeMilliseconds", "GetRecords.Latency", "GetRecords.Success"},
|
||||
"AWS/Lambda": {"Invocations", "Errors", "Duration", "Throttles"},
|
||||
"AWS/Logs": {"IncomingBytes", "IncomingLogEvents", "ForwardedBytes", "ForwardedLogEvents", "DeliveryErrors", "DeliveryThrottling"},
|
||||
"AWS/ML": {"PredictCount", "PredictFailureCount"},
|
||||
"AWS/OpsWorks": {"cpu_idle", "cpu_nice", "cpu_system", "cpu_user", "cpu_waitio", "load_1", "load_5", "load_15", "memory_buffers", "memory_cached", "memory_free", "memory_swap", "memory_total", "memory_used", "procs"},
|
||||
"AWS/Redshift": {"CPUUtilization", "DatabaseConnections", "HealthStatus", "MaintenanceMode", "NetworkReceiveThroughput", "NetworkTransmitThroughput", "PercentageDiskSpaceUsed", "ReadIOPS", "ReadLatency", "ReadThroughput", "WriteIOPS", "WriteLatency", "WriteThroughput"},
|
||||
@@ -85,8 +87,10 @@ func init() {
|
||||
"AWS/ELB": {"LoadBalancerName", "AvailabilityZone"},
|
||||
"AWS/ElasticMapReduce": {"ClusterId", "JobFlowId", "JobId"},
|
||||
"AWS/ES": {},
|
||||
"AWS/Events": {"RuleName"},
|
||||
"AWS/Kinesis": {"StreamName"},
|
||||
"AWS/Lambda": {"FunctionName"},
|
||||
"AWS/Logs": {"LogGroupName", "DestinationType", "FilterName"},
|
||||
"AWS/ML": {"MLModelId", "RequestMode"},
|
||||
"AWS/OpsWorks": {"StackId", "LayerId", "InstanceId"},
|
||||
"AWS/Redshift": {"NodeID", "ClusterIdentifier"},
|
||||
|
||||
@@ -116,6 +116,25 @@ func GetDataSourceByName(c *middleware.Context) Response {
|
||||
return Json(200, &dtos)
|
||||
}
|
||||
|
||||
// Get /api/datasources/id/:name
|
||||
func GetDataSourceIdByName(c *middleware.Context) Response {
|
||||
query := m.GetDataSourceByNameQuery{Name: c.Params(":name"), OrgId: c.OrgId}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if err == m.ErrDataSourceNotFound {
|
||||
return ApiError(404, "Data source not found", nil)
|
||||
}
|
||||
return ApiError(500, "Failed to query datasources", err)
|
||||
}
|
||||
|
||||
ds := query.Result
|
||||
dtos := dtos.AnyId{
|
||||
Id: ds.Id,
|
||||
}
|
||||
|
||||
return Json(200, &dtos)
|
||||
}
|
||||
|
||||
func convertModelToDtos(ds m.DataSource) dtos.DataSource {
|
||||
return dtos.DataSource{
|
||||
Id: ds.Id,
|
||||
|
||||
@@ -10,6 +10,10 @@ import (
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type AnyId struct {
|
||||
Id int64 `json:"id"`
|
||||
}
|
||||
|
||||
type LoginCommand struct {
|
||||
User string `json:"user" binding:"Required"`
|
||||
Password string `json:"password" binding:"Required"`
|
||||
|
||||
+16
-11
@@ -48,18 +48,23 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
|
||||
data.User.LightTheme = true
|
||||
}
|
||||
|
||||
dashboardChildNavs := []*dtos.NavLink{
|
||||
{Text: "Home", Url: setting.AppSubUrl + "/"},
|
||||
{Text: "Playlists", Url: setting.AppSubUrl + "/playlists"},
|
||||
{Text: "Snapshots", Url: setting.AppSubUrl + "/dashboard/snapshots"},
|
||||
}
|
||||
|
||||
if c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR {
|
||||
dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{Divider: true})
|
||||
dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{Text: "New", Url: setting.AppSubUrl + "/dashboard/new"})
|
||||
dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{Text: "Import", Url: setting.AppSubUrl + "/import/dashboard"})
|
||||
}
|
||||
|
||||
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
|
||||
Text: "Dashboards",
|
||||
Icon: "icon-gf icon-gf-dashboard",
|
||||
Url: setting.AppSubUrl + "/",
|
||||
Children: []*dtos.NavLink{
|
||||
{Text: "Home", Url: setting.AppSubUrl + "/"},
|
||||
{Text: "Playlists", Url: setting.AppSubUrl + "/playlists"},
|
||||
{Text: "Snapshots", Url: setting.AppSubUrl + "/dashboard/snapshots"},
|
||||
{Divider: true},
|
||||
{Text: "New", Url: setting.AppSubUrl + "/dashboard/new"},
|
||||
{Text: "Import", Url: setting.AppSubUrl + "/import/dashboard"},
|
||||
},
|
||||
Text: "Dashboards",
|
||||
Icon: "icon-gf icon-gf-dashboard",
|
||||
Url: setting.AppSubUrl + "/",
|
||||
Children: dashboardChildNavs,
|
||||
})
|
||||
|
||||
if c.OrgRole == m.ROLE_ADMIN {
|
||||
|
||||
@@ -31,6 +31,7 @@ func RenderToPng(c *middleware.Context) {
|
||||
Width: queryReader.Get("width", "800"),
|
||||
Height: queryReader.Get("height", "400"),
|
||||
SessionId: c.Session.ID(),
|
||||
Timeout: queryReader.Get("timeout", "15"),
|
||||
}
|
||||
|
||||
renderOpts.Url = setting.ToAbsUrl(renderOpts.Url)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/grafana/grafana/pkg/cmd/grafana-cli/log"
|
||||
m "github.com/grafana/grafana/pkg/cmd/grafana-cli/models"
|
||||
s "github.com/grafana/grafana/pkg/cmd/grafana-cli/services"
|
||||
@@ -64,32 +65,33 @@ func InstallPlugin(pluginName, version string, c CommandLine) error {
|
||||
return err
|
||||
}
|
||||
|
||||
url := v.Url
|
||||
commit := v.Commit
|
||||
|
||||
if version == "" {
|
||||
version = v.Version
|
||||
}
|
||||
|
||||
downloadURL := url + "/archive/" + commit + ".zip"
|
||||
downloadURL := fmt.Sprintf("%s/%s/versions/%s/download",
|
||||
c.GlobalString("repo"),
|
||||
pluginName,
|
||||
version)
|
||||
|
||||
log.Infof("installing %v @ %v\n", plugin.Id, version)
|
||||
log.Infof("from url: %v\n", downloadURL)
|
||||
log.Infof("on commit: %v\n", commit)
|
||||
log.Infof("into: %v\n", pluginFolder)
|
||||
|
||||
err = downloadFile(plugin.Id, pluginFolder, downloadURL)
|
||||
if err == nil {
|
||||
log.Infof("Installed %v successfully ✔\n", plugin.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, _ := s.ReadPlugin(pluginFolder, pluginName)
|
||||
log.Infof("Installed %v successfully ✔\n", plugin.Id)
|
||||
|
||||
/* Enable once we need support for downloading depedencies
|
||||
res, _ := s.ReadPlugin(pluginFolder, pluginName)
|
||||
for _, v := range res.Dependency.Plugins {
|
||||
InstallPlugin(v.Id, version, c)
|
||||
log.Infof("Installed Dependency: %v ✔\n", v.Id)
|
||||
log.Infof("Installed dependency: %v ✔\n", v.Id)
|
||||
}
|
||||
|
||||
*/
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
var ls_getPlugins func(path string) []m.InstalledPlugin = s.GetLocalPlugins
|
||||
|
||||
var validateLsCommmand = func(pluginDir string) error {
|
||||
var validateLsCommand = func(pluginDir string) error {
|
||||
if pluginDir == "" {
|
||||
return errors.New("missing path flag")
|
||||
}
|
||||
@@ -31,7 +31,7 @@ var validateLsCommmand = func(pluginDir string) error {
|
||||
|
||||
func lsCommand(c CommandLine) error {
|
||||
pluginDir := c.GlobalString("path")
|
||||
if err := validateLsCommmand(pluginDir); err != nil {
|
||||
if err := validateLsCommand(pluginDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
func TestMissingPath(t *testing.T) {
|
||||
var org = validateLsCommmand
|
||||
var org = validateLsCommand
|
||||
|
||||
Convey("ls command", t, func() {
|
||||
validateLsCommmand = org
|
||||
validateLsCommand = org
|
||||
|
||||
Convey("Missing path", func() {
|
||||
commandLine := &commandstest.FakeCommandLine{
|
||||
@@ -61,7 +61,7 @@ func TestMissingPath(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
validateLsCommmand = func(pluginDir string) error {
|
||||
validateLsCommand = func(pluginDir string) error {
|
||||
return errors.New("dummie error")
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "repo",
|
||||
Usage: "url to the plugin repository",
|
||||
Value: "https://raw.githubusercontent.com/grafana/grafana-plugin-repository/master/repo.json",
|
||||
Value: "",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "debug, d",
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
var IoHelper m.IoUtil = IoUtilImp{}
|
||||
|
||||
func ListAllPlugins(repoUrl string) (m.PluginRepo, error) {
|
||||
res, _ := goreq.Request{Uri: repoUrl}.Do()
|
||||
|
||||
res, _ := goreq.Request{Uri: repoUrl + "/repo", MaxRedirects: 3}.Do()
|
||||
|
||||
var resp m.PluginRepo
|
||||
err := res.Body.FromJsonTo(&resp)
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type RenderOpts struct {
|
||||
@@ -18,6 +19,7 @@ type RenderOpts struct {
|
||||
Width string
|
||||
Height string
|
||||
SessionId string
|
||||
Timeout string
|
||||
}
|
||||
|
||||
func RenderToPng(params *RenderOpts) (string, error) {
|
||||
@@ -60,8 +62,13 @@ func RenderToPng(params *RenderOpts) (string, error) {
|
||||
close(done)
|
||||
}()
|
||||
|
||||
timeout, err := strconv.Atoi(params.Timeout)
|
||||
if err != nil {
|
||||
timeout = 15
|
||||
}
|
||||
|
||||
select {
|
||||
case <-time.After(15 * time.Second):
|
||||
case <-time.After(time.Duration(timeout) * time.Second):
|
||||
if err := cmd.Process.Kill(); err != nil {
|
||||
log.Error(4, "failed to kill: %v", err)
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ func TestPluginDashboards(t *testing.T) {
|
||||
|
||||
Convey("When asking plugin dashboard info", t, func() {
|
||||
setting.Cfg = ini.Empty()
|
||||
sec, _ := setting.Cfg.NewSection("plugin.nginx-app")
|
||||
sec.NewKey("path", "../../examples/nginx-app")
|
||||
sec, _ := setting.Cfg.NewSection("plugin.test-app")
|
||||
sec.NewKey("path", "../../tests/test-app")
|
||||
err := Init()
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
@@ -31,7 +31,7 @@ func TestPluginDashboards(t *testing.T) {
|
||||
return m.ErrDashboardNotFound
|
||||
})
|
||||
|
||||
dashboards, err := GetPluginDashboards(1, "nginx-app")
|
||||
dashboards, err := GetPluginDashboards(1, "test-app")
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestPluginDashboards(t *testing.T) {
|
||||
So(dashboards[0].Title, ShouldEqual, "Nginx Connections")
|
||||
So(dashboards[0].Revision, ShouldEqual, "1.5")
|
||||
So(dashboards[0].InstalledRevision, ShouldEqual, "1.1")
|
||||
So(dashboards[0].InstalledURI, ShouldEqual, "db/nginx-connections")
|
||||
So(dashboards[0].InstalledUri, ShouldEqual, "db/nginx-connections")
|
||||
|
||||
So(dashboards[1].Revision, ShouldEqual, "2.0")
|
||||
So(dashboards[1].InstalledRevision, ShouldEqual, "")
|
||||
|
||||
@@ -28,14 +28,14 @@ func TestPluginScans(t *testing.T) {
|
||||
Convey("When reading app plugin definition", t, func() {
|
||||
setting.Cfg = ini.Empty()
|
||||
sec, _ := setting.Cfg.NewSection("plugin.nginx-app")
|
||||
sec.NewKey("path", "../../examples/nginx-app")
|
||||
sec.NewKey("path", "../../tests/test-app")
|
||||
err := Init()
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(len(Apps), ShouldBeGreaterThan, 0)
|
||||
|
||||
So(Apps["nginx-app"].Info.Logos.Large, ShouldEqual, "public/plugins/nginx-app/img/logo_large.png")
|
||||
So(Apps["nginx-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/nginx-app/img/screenshot2.png")
|
||||
So(Apps["test-app"].Info.Logos.Large, ShouldEqual, "public/plugins/test-app/img/logo_large.png")
|
||||
So(Apps["test-app"].Info.Screenshots[1].Path, ShouldEqual, "public/plugins/test-app/img/screenshot2.png")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user