Skip to content

Commit

Permalink
Added statistics collection for query optimization (#306)
Browse files Browse the repository at this point in the history
* added query for collect data

* Changed collect data

* setting web server for api

* added collect table performance_schema.file_summary_by_instance

* Increased timeout

* increased version
  • Loading branch information
kochetovd authored May 22, 2024
1 parent 219df7a commit ad6702f
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 58 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
ReleemAgentVersion = "1.15.0"
ReleemAgentVersion = "1.16.0"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion current_version_agent
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.0
1.16.0
30 changes: 22 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash
# install.sh - Version 1.15.0
# install.sh - Version 1.16.0
# (C) Releem, Inc 2022
# All rights reserved

# Releem installation script: install and set up the Releem Agent on supported Linux distributions
# using the package manager.

set -e
install_script_version=1.15.0
install_script_version=1.16.0
logfile="releem-install.log"

WORKDIR="/opt/releem"
Expand Down Expand Up @@ -119,17 +119,25 @@ if [ -n "$RELEEM_MYSQL_HOST" ]; then
mysql_user_host="%"
fi
connection_string="${connection_string} --host=${RELEEM_MYSQL_HOST}"

if [ -n "$RELEEM_MYSQL_PORT" ]; then
connection_string="${connection_string} --port=${RELEEM_MYSQL_PORT}"
else
connection_string="${connection_string} --port=3306"
fi
fi
else
mysql_user_host="127.0.0.1"
connection_string="${connection_string} --host=127.0.0.1"

if [ -n "$RELEEM_MYSQL_PORT" ]; then
connection_string="${connection_string} --port=${RELEEM_MYSQL_PORT}"
else
connection_string="${connection_string} --port=3306"
fi
fi

if [ -n "$RELEEM_MYSQL_PORT" ]; then
connection_string="${connection_string} --port=${RELEEM_MYSQL_PORT}"
else
connection_string="${connection_string} --port=3306"
fi




Expand Down Expand Up @@ -300,8 +308,14 @@ else
else
printf "\033[31m\n This database version is too old, and it doesn’t collect SQL Queries Latency metrics. You couldn’t see Latency in the Dashboard.\033[0m\n"
fi

if mysql ${root_connection_string} --user=root --password=${RELEEM_MYSQL_ROOT_PASSWORD} -Be "GRANT SELECT ON performance_schema.table_io_waits_summary_by_index_usage TO '${RELEEM_MYSQL_LOGIN}'@'${mysql_user_host}';"
then
echo "Successfully GRANT" > /dev/null
else
printf "\033[31m\n This database version is too old.\033[0m\n"
fi

if mysql ${root_connection_string} --user=root --password=${RELEEM_MYSQL_ROOT_PASSWORD} -Be "GRANT SELECT ON performance_schema.file_summary_by_instance TO '${RELEEM_MYSQL_LOGIN}'@'${mysql_user_host}';"
then
echo "Successfully GRANT" > /dev/null
else
Expand Down
24 changes: 12 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func IsPath(path string, logger logging.Logger) bool {
}

// Manage by daemon commands or run the daemon
func (service *Service) Manage(logger logging.Logger, configFile string, command []string, TypeConfiguration string, AgentEvents string, AgentTask string) (string, error) {
func (service *Service) Manage(logger logging.Logger, configFile string, command []string, TypeConfiguration string, AgentEvent string, AgentTask string) (string, error) {
var gatherers, gatherers_configuration []m.MetricsGatherer
var Mode m.Mode
var configuration *config.Config
Expand Down Expand Up @@ -89,17 +89,17 @@ func (service *Service) Manage(logger logging.Logger, configFile string, command
os.Exit(0)
}

if len(AgentEvents) > 0 {
Mode.Name = "Events"
Mode.ModeType = AgentEvents
if len(AgentEvent) > 0 {
Mode.Name = "Event"
Mode.ModeType = AgentEvent
} else if len(AgentTask) > 0 {
Mode.Name = "Task"
Mode.Name = "TaskSet"
Mode.ModeType = AgentTask
} else {
Mode.Name = "Configurations"
Mode.ModeType = TypeConfiguration
}
// if Mode.Name != "Events" {
// if Mode.Name != "Event" {
// Select how we collect instance metrics depending on InstanceType
switch configuration.InstanceType {
case "aws/rds":
Expand Down Expand Up @@ -190,10 +190,10 @@ func (service *Service) Manage(logger logging.Logger, configFile string, command
repeaters := make(map[string]m.MetricsRepeater)
repeaters["Metrics"] = m.MetricsRepeater(r.NewReleemMetricsRepeater(configuration))
repeaters["Configurations"] = m.MetricsRepeater(r.NewReleemConfigurationsRepeater(configuration, Mode))
repeaters["Events"] = m.MetricsRepeater(r.NewReleemEventsRepeater(configuration, Mode))
repeaters["Tasks"] = m.MetricsRepeater(t.NewReleemTasksRepeater(configuration))
repeaters["Event"] = m.MetricsRepeater(r.NewReleemEventRepeater(configuration, Mode))
repeaters["TaskGet"] = m.MetricsRepeater(t.NewReleemTaskGetRepeater(configuration))
repeaters["TaskStatus"] = m.MetricsRepeater(t.NewReleemTaskStatusRepeater(configuration))
repeaters["Task"] = m.MetricsRepeater(t.NewReleemTaskSetRepeater(configuration, Mode))
repeaters["TaskSet"] = m.MetricsRepeater(t.NewReleemTaskSetRepeater(configuration, Mode))

//Init gatherers
gatherers = append(gatherers,
Expand All @@ -202,7 +202,7 @@ func (service *Service) Manage(logger logging.Logger, configFile string, command
m.NewDbMetricsBaseGatherer(nil, db, configuration),
m.NewAgentMetricsGatherer(nil, configuration))
gatherers_configuration = append(gatherers_configuration, m.NewDbMetricsGatherer(nil, db, configuration))
if Mode.Name == "Task" && Mode.ModeType == "collect_queries" {
if Mode.Name == "TaskSet" && Mode.ModeType == "collect_queries" {
gatherers = append(gatherers, m.NewDbCollectQueries(nil, db, configuration))
}
m.RunWorker(gatherers, gatherers_configuration, repeaters, nil, configuration, configFile, Mode)
Expand All @@ -219,7 +219,7 @@ func main() {
SetConfigRun := flag.Bool("f", false, "Releem agent generate config")
GetConfigRun := flag.Bool("c", false, "Releem agent generate config")

AgentEvents := flag.String("event", "", "Releem agent type event")
AgentEvent := flag.String("event", "", "Releem agent type event")
AgentTask := flag.String("task", "", "Releem agent task name")

flag.Parse()
Expand All @@ -238,7 +238,7 @@ func main() {
os.Exit(1)
}
service := &Service{srv}
status, err := service.Manage(logger, *configFile, command, TypeConfiguration, *AgentEvents, *AgentTask)
status, err := service.Manage(logger, *configFile, command, TypeConfiguration, *AgentEvent, *AgentTask)

if err != nil {
logger.Println(status, "\nError: ", err)
Expand Down
5 changes: 3 additions & 2 deletions metrics/Metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ type Metrics struct {
Conf struct {
Variables MetricGroupValue
}
Info MetricGroupValue
Queries []MetricGroupValue
Info MetricGroupValue
Queries []MetricGroupValue
QueriesOptimization map[string][]MetricGroupValue
}
ReleemAgent struct {
Info MetricGroupValue
Expand Down
Loading

0 comments on commit ad6702f

Please sign in to comment.