Example #1
0
func main() {
	flag.Parse()
	common.SetupLogger()

	config := common.LoadConfig()

	cassandraConfig := cassandra.CassandraMetricMetadataConfig{
		Hosts:    config.MetricMetadataConfig.Hosts,
		Keyspace: config.MetricMetadataConfig.Keyspace,
	}
	apiInstance := common.NewMetricMetadataAPI(cassandraConfig)

	ruleset, err := util.LoadRules(config.MetricMetadataConfig.ConversionRulesPath)
	if err != nil {
		//Blah
	}
	graphite := util.RuleBasedGraphiteConverter{Ruleset: ruleset}
	config.Blueflood.GraphiteMetricConverter = &graphite

	blueflood := blueflood.NewBlueflood(config.Blueflood)

	optimizer := optimize.NewOptimizationConfiguration()
	optimizer.EnableMetricMetadataCaching = true

	startServer(config.UIConfig, query.ExecutionContext{
		MetricMetadataAPI:         apiInstance,
		TimeseriesStorageAPI:      blueflood,
		FetchLimit:                1000,
		SlotLimit:                 5000,
		Registry:                  registry.Default(),
		OptimizationConfiguration: optimizer,
	})
}
Example #2
0
func main() {
	flag.Parse()
	common.SetupLogger()

	config := common.LoadConfig()

	ruleset, err := internal.LoadRules(config.API.ConversionRulesPath)
	if err != nil {
		common.ExitWithMessage(fmt.Sprintf("Error while reading rules: %s", err.Error()))
	}
	metricFile, err := os.Open(*metricsFile)
	if err != nil {
		common.ExitWithMessage("No metric file.")
	}
	scanner := bufio.NewScanner(metricFile)
	apiInstance := common.NewAPI(config.API)
	var output *os.File
	if *unmatchedFile != "" {
		output, err = os.Create(*unmatchedFile)
		if err != nil {
			common.ExitWithMessage(fmt.Sprintf("Error creating the output file: %s", err.Error()))
		}
	}
	stat := run(ruleset, scanner, apiInstance, output)
	report(stat)
}
Example #3
0
func main() {
	flag.Parse()
	common.SetupLogger()

	config := common.LoadConfig()

	cassandraConfig := cassandra.CassandraMetricMetadataConfig{
		Hosts:    config.MetricMetadataConfig.Hosts,
		Keyspace: config.MetricMetadataConfig.Keyspace,
	}
	apiInstance := common.NewMetricMetadataAPI(cassandraConfig)

	ruleset, err := util.LoadRules(config.MetricMetadataConfig.ConversionRulesPath)
	if err != nil {
		//Blah
	}
	graphite := util.RuleBasedGraphiteConverter{Ruleset: ruleset}
	config.Blueflood.GraphiteMetricConverter = &graphite

	blueflood := blueflood.NewBlueflood(config.Blueflood)

	l := liner.NewLiner()
	defer l.Close()
	for {
		input, err := l.Prompt("> ")
		if err != nil {
			return
		}

		l.AppendHistory(input)

		cmd, err := query.Parse(input)
		if err != nil {
			fmt.Println("parsing error", err.Error())
			continue
		}

		n, ok := cmd.(query.Node)
		if !ok {
			fmt.Printf("error: %#v doesn't implement Node\n", cmd)
			continue
		}
		fmt.Println(query.PrintNode(n))

		result, err := cmd.Execute(query.ExecutionContext{TimeseriesStorageAPI: blueflood, MetricMetadataAPI: apiInstance, FetchLimit: 1000})
		if err != nil {
			fmt.Println("execution error:", err.Error())
			continue
		}
		encoded, err := json.MarshalIndent(result, "", "  ")
		if err != nil {
			fmt.Println("encoding error:", err.Error())
			return
		}
		fmt.Println("success:")
		fmt.Println(string(encoded))
	}
}
Example #4
0
func main() {
	flag.Parse()
	common.SetupLogger()

	//Adding a signal handler to dump goroutines
	sigs := make(chan os.Signal, 1)
	signal.Notify(sigs, syscall.SIGUSR2)

	go func() {
		for _ = range sigs {
			pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
		}
	}()

	config := common.LoadConfig()

	cassandraConfig := cassandra.CassandraMetricMetadataConfig{
		Hosts:    config.MetricMetadataConfig.Hosts,
		Keyspace: config.MetricMetadataConfig.Keyspace,
	}
	apiInstance := common.NewMetricMetadataAPI(cassandraConfig)

	ruleset, err := util.LoadRules(config.MetricMetadataConfig.ConversionRulesPath)
	if err != nil {
		//Blah
	}
	graphite := util.RuleBasedGraphiteConverter{Ruleset: ruleset}
	config.Blueflood.GraphiteMetricConverter = &graphite

	blueflood := blueflood.NewBlueflood(config.Blueflood)

	optimizer := optimize.NewOptimizationConfiguration()
	optimizer.EnableMetricMetadataCaching = true

	//Defaults
	userConfig := api.UserSpecifiableConfig{
		IncludeRawData: false,
	}

	startServer(config.UIConfig, query.ExecutionContext{
		MetricMetadataAPI:         apiInstance,
		TimeseriesStorageAPI:      blueflood,
		FetchLimit:                1500,
		SlotLimit:                 5000,
		Registry:                  registry.Default(),
		OptimizationConfiguration: optimizer,
		UserSpecifiableConfig:     userConfig,
	})
}
Example #5
0
func main() {
	flag.Parse()
	common.SetupLogger()

	config := common.LoadConfig()

	apiInstance := common.NewAPI(config.API)
	myBackend := blueflood.NewBlueflood(config.Blueflood)

	l := liner.NewLiner()
	defer l.Close()
	for {
		input, err := l.Prompt("> ")
		if err != nil {
			return
		}

		l.AppendHistory(input)

		cmd, err := query.Parse(input)
		if err != nil {
			fmt.Println("parsing error", err.Error())
			continue
		}

		n, ok := cmd.(query.Node)
		if !ok {
			fmt.Printf("error: %#v doesn't implement Node\n", cmd)
			continue
		}
		fmt.Println(query.PrintNode(n))

		result, err := cmd.Execute(query.ExecutionContext{Backend: backend.NewSequentialMultiBackend(myBackend), API: apiInstance, FetchLimit: 1000})
		if err != nil {
			fmt.Println("execution error:", err.Error())
			continue
		}
		encoded, err := json.MarshalIndent(result, "", "  ")
		if err != nil {
			fmt.Println("encoding error:", err.Error())
			return
		}
		fmt.Println("success:")
		fmt.Println(string(encoded))
	}
}
Example #6
0
func main() {
	flag.Parse()
	common.SetupLogger()

	config := common.LoadConfig()

	apiInstance := common.NewAPI(config.API)

	blueflood := api.ProfilingBackend{
		Backend: blueflood.NewBlueflood(config.Blueflood),
	}
	backend := api.ProfilingMultiBackend{
		MultiBackend: backend.NewParallelMultiBackend(blueflood, 20),
	}

	ui.Main(config.UIConfig, query.ExecutionContext{
		API: apiInstance, Backend: backend, FetchLimit: 1000,
		Registry: registry.Default(),
	})
}
Example #7
0
func main() {
	if os.Getenv("GOMAXPROCS") == "" {
		runtime.GOMAXPROCS(runtime.NumCPU())
	}
	flag.Parse()
	common.SetupLogger()

	if *metricsFile == "" {
		common.ExitWithMessage("No metric file specified. Use '-metrics-file'")
	}

	if *rulePath == "" {
		common.ExitWithMessage("No rule path specified. Use '-rule-path'")
	}

	//TODO(cchandler): Make a constructor for a graphite converter so we don't
	//have to stich everything together outside of the package.

	ruleset, err := util.LoadRules(*rulePath)
	if err != nil {
		common.ExitWithMessage(fmt.Sprintf("Error while reading rules: %s", err.Error()))
	}

	graphiteConverter := util.RuleBasedGraphiteConverter{Ruleset: ruleset}

	metrics, err := ReadMetricsFile(*metricsFile)
	if err != nil {
		fmt.Printf("Fatal error reading metrics file %s\n", err)
		os.Exit(1)
	}

	classifiedMetrics := DoAnalysis(metrics, graphiteConverter)
	fmt.Printf("Generating report files...\n")
	GenerateReport(classifiedMetrics[Unmatched], graphiteConverter)

	fmt.Printf("Total metric count %d\n", len(metrics))
}