Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename GRRafana to Grafana Source Server #897

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion grr/core/grr_response_core/config/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
WORKER_CONTEXT = config_lib.DEFINE_context("Worker Context")
FS_FRONTEND_CONTEXT = config_lib.DEFINE_context("FleetspeakFrontend Context")
BENCHMARK_CONTEXT = config_lib.DEFINE_context("Benchmark Context")
GRRAFANA_CONTEXT = config_lib.DEFINE_context("GRRafana Context")
GRAFANA_SOURCE_SERVER_CONTEXT = config_lib.DEFINE_context("Grafana Source Server Context")

# Client building contexts.
CLIENT_BUILD_CONTEXT = config_lib.DEFINE_context("ClientBuilder Context")
Expand Down
6 changes: 3 additions & 3 deletions grr/core/grr_response_core/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@
"If the average network usage per client becomes "
"greater than this limit, the hunt gets stopped.")

# GRRafana HTTP Server settings.
# Grafana Source HTTP Server settings.
config_lib.DEFINE_string(
"GRRafana.bind", default="localhost", help="The GRRafana server address.")
"GrafanaSourceServer.bind", default="localhost", help="The Grafana Source Server address.")

config_lib.DEFINE_integer(
"GRRafana.port", default=5000, help="The GRRafana server port.")
"GrafanaSourceServer.port", default=5000, help="The Grafana Source Server port.")

# Fleetspeak server-side integration flags.
config_lib.DEFINE_string(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def ProcessQuery(
}


class Grrafana(object):
"""GRRafana HTTP server instance.
class GrafanaSourceServer(object):
"""Grafana Source HTTP server instance.

A full description of all endpoints implemented within this HTTP
server can be found in:
Expand Down Expand Up @@ -278,15 +278,15 @@ def main(argv: Any) -> None:
del argv # Unused.

if flags.FLAGS.version:
print(f"GRRafana server {config_server.VERSION['packageversion']}")
print(f"Grafana Source Server {config_server.VERSION['packageversion']}")
return

config.CONFIG.AddContext(contexts.GRRAFANA_CONTEXT,
"Context applied when running GRRafana server.")
config.CONFIG.AddContext(contexts.GRAFANA_SOURCE_SERVER_CONTEXT,
"Context applied when running Grafana Source Server.")
server_startup.Init()
fleetspeak_connector.Init()
werkzeug_serving.run_simple(config.CONFIG["GRRafana.bind"],
config.CONFIG["GRRafana.port"], Grrafana())
werkzeug_serving.run_simple(config.CONFIG["GrafanaSourceServer.bind"],
config.CONFIG["GrafanaSourceServer.port"], GrafanaSourceServer())


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# Lint as: python3
"""Unittest for GRRafana HTTP server."""
"""Unittest for Grafana Source HTTP Server."""
import copy

from absl import app
Expand All @@ -12,7 +12,7 @@

from grr_response_server import data_store
from grr_response_server import fleetspeak_connector
from grr_response_server.bin import grrafana
from grr_response_server.bin import grafana_source_server
from grr_response_server.fleet_utils import FleetStats

from fleetspeak.src.server.proto.fleetspeak_server import admin_pb2
Expand Down Expand Up @@ -67,7 +67,7 @@
"max_resident_memory_mib": 59
}
_TEST_CLIENT_BREAKDOWN_STATS = FleetStats(
day_buckets=grrafana._FLEET_BREAKDOWN_DAY_BUCKETS,
day_buckets=grafana_source_server._FLEET_BREAKDOWN_DAY_BUCKETS,
label_counts={
1: {
"foo-label": {
Expand Down Expand Up @@ -267,13 +267,14 @@ def _MockDatastoreReturningPlatformFleetStats(client_fleet_stats):
return rel_db


class GrrafanaTest(absltest.TestCase):
"""Test the GRRafana HTTP server."""
class GrafanaSourceServerTest(absltest.TestCase):
"""Test the Grafana Source HTTP Server."""

def setUp(self):
super(GrrafanaTest, self).setUp()
super(GrafanaSourceServerTest, self).setUp()
self.client = werkzeug_test.Client(
application=grrafana.Grrafana(), response_wrapper=grrafana.JSONResponse)
application=grafana_source_server.GrafanaSourceServer(),
response_wrapper=grafana_source_server.JSONResponse)

def testRoot(self):
response = self.client.get("/")
Expand All @@ -294,15 +295,15 @@ def testSearchMetrics(self):
]
expected_res.extend([
f"OS Platform Breakdown - {n_days} Day Active"
for n_days in grrafana._FLEET_BREAKDOWN_DAY_BUCKETS
for n_days in grafana_source_server._FLEET_BREAKDOWN_DAY_BUCKETS
])
expected_res.extend([
f"OS Release Version Breakdown - {n_days} Day Active"
for n_days in grrafana._FLEET_BREAKDOWN_DAY_BUCKETS
for n_days in grafana_source_server._FLEET_BREAKDOWN_DAY_BUCKETS
])
expected_res.extend([
f"Client Version Strings - {n_days} Day Active"
for n_days in grrafana._FLEET_BREAKDOWN_DAY_BUCKETS
for n_days in grafana_source_server._FLEET_BREAKDOWN_DAY_BUCKETS
])
self.assertListEqual(response.json, expected_res)

Expand Down Expand Up @@ -361,10 +362,10 @@ class TimeToProtoTimestampTest(absltest.TestCase):

def testTimeToProtoTimestamp(self):
self.assertEqual(
grrafana.TimeToProtoTimestamp(_START_RANGE_TIMESTAMP),
grafana_source_server.TimeToProtoTimestamp(_START_RANGE_TIMESTAMP),
timestamp_pb2.Timestamp(seconds=1597328417, nanos=(158 * 1000000)))
self.assertEqual(
grrafana.TimeToProtoTimestamp(_END_RANGE_TIMESTAMP),
grafana_source_server.TimeToProtoTimestamp(_END_RANGE_TIMESTAMP),
timestamp_pb2.Timestamp(seconds=1597770958, nanos=(761 * 1000000)))


Expand Down
10 changes: 5 additions & 5 deletions grr/server/grr_response_server/bin/grr_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from grr_response_server import server_startup
from grr_response_server.bin import fleetspeak_frontend
from grr_response_server.bin import frontend
from grr_response_server.bin import grrafana
from grr_response_server.bin import grafana_source_server
from grr_response_server.bin import worker
from grr_response_server.gui import admin_ui

Expand All @@ -30,7 +30,7 @@
help="Print the GRR server version number and exit immediately.")

flags.DEFINE_string("component", None,
"Component to start: [frontend|admin_ui|worker|grrafana].")
"Component to start: [frontend|admin_ui|worker|grafana_source_server].")


def main(argv):
Expand Down Expand Up @@ -62,9 +62,9 @@ def main(argv):
elif flags.FLAGS.component.startswith("admin_ui"):
admin_ui.main([argv])

# Start as GRRafana.
elif flags.FLAGS.component.startswith("grrafana"):
grrafana.main([argv])
# Start as Grafana Source Server.
elif flags.FLAGS.component.startswith("grafana_source_server"):
grafana_source_server.main([argv])

# Raise on invalid component.
else:
Expand Down
6 changes: 3 additions & 3 deletions grr/server/grr_response_server/distro_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ def AdminUI():
app.run(admin_ui.main)


def Grrafana():
from grr_response_server.bin import grrafana
app.run(grrafana.main)
def GrafanaSourceServer():
from grr_response_server.bin import grafana_source_server
app.run(grafana_source_server.main)
6 changes: 3 additions & 3 deletions monitoring/grafana/grr_grafanalib_dashboards/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# The data source names are specified after Grafana is set up
# and it can be visited at localhost:3000.
# In GRR Monitoring docs, we suggest naming the data sources "grr-server"
# and "grrafana" respectively, but if it's not the case, change it here.
# and "grafana-source-server" respectively, but if it's not the case, change it here.
# For reference, take a look at the docs here:
# https://grr-doc.readthedocs.io/en/latest/maintaining-and-tuning/monitoring.html#example-visualization-and-alerting-setup
# https://grr-doc.readthedocs.io/en/latest/maintaining-and-tuning/monitoring.html#grafana-setup
GRAFANA_DATA_SOURCE = "grr-server"
CLIENT_LOAD_STATS_DATA_SOURCE = "grrafana"
CLIENT_LOAD_STATS_DATA_SOURCE = "grafana-source-server"

# An alert will be fired if the number of active processes (of any
# GRR server component) is below this number.
Expand Down