### Run Druid Instance with Docker Source: https://github.com/a0x8o/scruid/blob/master/README.md Command to start a Druid instance using Docker for testing purposes. It maps the necessary ports for communication. ```bash docker run --rm -i -p 8082:8082 -p 8081:8081 fokkodriesprong/docker-druid ``` -------------------------------- ### Druid Configuration Example Source: https://github.com/a0x8o/scruid/blob/master/README.md Defines the Typesafe configuration for connecting to Druid, including host, port, and datasource. Environment variables can override these settings. ```hocon druid = { host = "localhost" host = ${?DRUID_HOST} port = 8082 port = ${?DRUID_PORT} secure = false secure = ${?DRUID_USE_SECURE_CONNECTION} url = "/druid/v2/" url = ${?DRUID_URL} datasource = "wikiticker" datasource = ${?DRUID_DATASOURCE} connectionTimeout = 10000 readTimeout = 30000 } ``` -------------------------------- ### TimeSeries Query Example Source: https://github.com/a0x8o/scruid/blob/master/README.md Illustrates constructing and executing a TimeSeries query to get hourly counts. The results are decoded into a map where keys are ZonedDateTimes and values are TimeseriesCount case classes. ```scala case class TimeseriesCount(count: Int) val response = TimeSeriesQuery( aggregations = List( CountAggregation(name = "count") ), granularity = "hour", intervals = List("2011-06-01/2017-06-01") ).execute val series: Map[ZonedDateTime, TimeseriesCount] = response.series[TimeseriesCount] ``` -------------------------------- ### TopN Query Example Source: https://github.com/a0x8o/scruid/blob/master/README.md Demonstrates how to construct and execute a TopN query to find the top 5 countries by count. The results are decoded into a list of TopCountry case class. ```scala case class TopCountry(count: Int, countryName: String = null) val response = TopNQuery( dimension = Dimension( dimension = "countryName" ), threshold = 5, metric = "count", aggregations = List( CountAggregation(name = "count") ), intervals = List("2011-06-01/2017-06-01") ).execute val result: Map[ZonedDateTime, List[TopCountry]] = response.series[List[TopCountry]] ``` -------------------------------- ### GroupBy Query Example Source: https://github.com/a0x8o/scruid/blob/master/README.md Shows how to build and execute a GroupBy query to aggregate data by 'isAnonymous'. The results are decoded into a list of GroupByIsAnonymous case class. Note that Druid returns booleans as strings, requiring JSON parser conversion. ```scala case class GroupByIsAnonymous(isAnonymous: Boolean, count: Int) val response = GroupByQuery( aggregations = List( CountAggregation(name = "count") ), dimensions = List("isAnonymous"), intervals = List("2011-06-01/2017-06-01") ).execute() val result: List[GroupByIsAnonymous] = response.list[GroupByIsAnonymous] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.