[
 {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title": "Queries By API Route",
    "code": "api_queries_by_route",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart" : {
            "terms" : {
              "field" : "api"
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["No. of Queries"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title": "Queries By API Function",
    "code": "api_queries_by_function",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg":{
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart" : {
            "terms" : {
              "field" : "route2"
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["No. of Queries"],
      "query": {"match_all": {}},
      "type":"BarChart",
      "options":{
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title": "Calls By API Time",
    "code": "api_queries_by_time",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart" : {
            "date_histogram": {
              "field": "datetime",
              "interval": "$ctrlChart.chart.interval"
            }
          }
        }
      },
      "form_schema":{
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day", "hour": "Hour", "minute": "Minute"},
          "default": "day"
        }
      },
      "series": ["Calls by Time"],
      "query": {"match_all": {}},
      "type":"BarChart",
      "options":{
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Calls By Time for a specific API Function",
    "code": "api_queries_per_function",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"term": { "api": "$ctrlChart.chart.api"  }  },
              {"term": { "route2": "$ctrlChart.chart.route2"  }  }
            ]
          }
        },
        "aggs": {
          "chart": {
              "date_histogram": {
                "field": "datetime",
                "interval": "$ctrlChart.chart.interval"
              }
          }
        }
      },
      "form_schema":{
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day", "hour": "Hour", "minute": "Minute"},
          "default": "day"
        },
        "api":  {
          "title": "API",
          "type": "string",
          "default": "admin"
        },
        "route2":  {
          "title": "Route 2",
          "type": "string",
          "default": "people"
        }
      },
      "series": ["Calls by time"],
      "query": {"match_all": {}},
      "type":"BarChart",
      "options":{
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Average For All API Calls",
    "code": "api_average_all_calls_bar",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "range": {
              "field": "time_taken",
              "ranges": [
                {"to": 0.1},
                {"to": 0.25},
                {"from": 0.25, "to": 0.5},
                {"from": 0.5, "to": 1.0},
                {"from": 1.0, "to": 2.0},
                {"from": 2.0, "to": 4.0},
                {"from": 5.0}
              ]
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["Api Routes"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Average For All API Calls",
    "code": "api_average_all_calls_bar_pie",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "range": {
              "field": "time_taken",
              "ranges": [
                {"to": 0.5},
                {"from": 0.5, "to": 1.0},
                {"from": 1.0, "to": 2.0},
                {"from": 2.0, "to": 4.0},
                {"from": 5.0}
              ]
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["Api Routes"],
      "query": {"match_all": {}},
      "type": "PieChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "% Calls by Time By API Route",
    "code": "api_pct_by_route",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "terms": {"field": "route2" },
            "aggs": {
              "chart": {
                "range": {
                  "field": "time_taken",
                  "ranges": [
                    {"to": 0.5},
                    {"from": 0.5, "to": 1.0},
                    {"from": 1.0, "to": 2.0},
                    {"from": 2.0, "to": 5.0},
                    {"from": 5.0}
                  ]
                }
              }
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": [
        {"key":"*-0.5", "label": "<500ms"},
        {"key":"0.5-1.0", "label": "500ms-1s"},
        {"key":"1.0-2.0", "label": "1s-2s"},
        {"key":"2.0-5.0", "label": "2s-5s"},
        {"key":"5.0-*", "label": ">5s"}
      ],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": "percent"
      }

    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Call by Time By API Route",
    "code": "api_call_time_by_route",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
        "agg": {
          "filter": {
            "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
          },
          "aggs": {
            "chart": {
              "terms": {"field": "route2" },
              "aggs": {
                "chart": {
                  "range": {
                    "field": "time_taken",
                    "ranges": [
                      {"to": 0.5},
                      {"from": 0.5, "to": 1.0},
                      {"from": 1.0, "to": 2.0},
                      {"from": 2.0, "to": 5.0},
                      {"from": 5.0}
                    ]
                  }
                }
              }
            }
          }
        },
        "form_schema": {
          "start_date":  {
            "title": "Start Date",
            "type": "relativedate",
            "default": "now-3d"
          },
          "end_date":  {
            "title": "End Date",
            "type": "relativedate",
            "default": "now"
          }
        },
        "series": [
          {"key":"*-0.5", "label": "<500ms"},
          {"key":"0.5-1.0", "label": "500ms-1s"},
          {"key":"1.0-2.0", "label": "1s-2s"},
          {"key":"2.0-5.0", "label": "2s-5s"},
          {"key":"5.0-*", "label": ">5s"}
        ],
        "query": {"match_all": {}},
        "type": "BarChart",
        "options": {
          "hAxis": {"minorGridlines": {"count": 3}},
          "legend": { "position": "top", "maxLines": 3 },
          "bar": { "groupWidth": "75%" },
          "isStacked": true
        }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title": "Average Time By API Route",
    "code": "api_queries_per_function",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "terms": {"field": "api" },
            "aggs": {
              "chart": {
                "avg" : {
                  "field" : "time_taken"
                }
              }
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["Api Routes"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Avg Time By API Function",
    "code": "api_avg_time_per_function",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
       "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "terms": {"field": "route2" },
            "aggs": {
              "chart": {
                "avg" : {
                  "field" : "time_taken"
                }
              }
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["APi Function"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Total Time By API Route",
    "code": "api_total_time_by_route",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "terms": {"field": "api" },
            "aggs": {
              "chart": {
                "sum" : {
                  "field" : "time_taken"
                }
              }
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["Api Routes"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title": "Total Time By API Function",
    "code": "api_total_time_by_function",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "terms": {"field": "route2" },
            "aggs": {
              "chart": {
                "sum" : {
                  "field" : "time_taken"
                }
              }
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "series": ["APi Function"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title": "Avg/Min/MaxDuration",
    "code": "api_avg_min_max_duration",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart" : {
            "date_histogram": {
              "field": "datetime",
              "interval": "$ctrlChart.chart.interval"
            },
            "aggs": {
              "chart1" : {"avg" : {"field": "time_taken"} },
              "chart2" : {"min" : {"field": "time_taken"} },
              "chart3" : {"max" : {"field": "time_taken"} }
            }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day", "hour": "Hour", "minute": "Minute"},
          "default": "day"
        }
      },
      "series": ["Avg", "Min", "Max"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": false
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "system",
    "title":  "Calls By Time for a specific API Function",
    "code": "api_call_time_specific",
    "panel": "google_chart_box",
    "config": {
      "source": "api",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"term": { "api": "$ctrlChart.chart.api"  }  },
              {"term": { "route2": "$ctrlChart.chart.route2"  }  }
            ]
          }
        },
        "aggs": {
          "chart" : {
              "date_histogram": {
                "field": "datetime",
                "interval": "$ctrlChart.chart.interval"
              }
          },
          "aggs": {
            "chart1" : {"add" : {"field": "time_taken"} }
          }
        }
      },
      "form_schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3d"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day", "hour": "Hour", "minute": "Minute"},
          "default": "day"
        },
        "api":  {
          "title": "API",
          "type": "string",
          "default": "admin"
        },
        "route2":  {
          "title": "Route 2",
          "type": "string",
          "default": "people"
        }
      },
      "series": ["Calls by time"],
      "query": {"match_all": {}},
      "type": "BarChart",
      "options": {
        "hAxis": {"minorGridlines": {"count": 3}},
        "legend": { "position": "top", "maxLines": 3 },
        "bar": { "groupWidth": "75%" },
        "isStacked": true
      }
    }
  }
]
