Enabling alerting capability to datasource plugin with dynamic dataframes

Have recently migrated to Grfana7.1.0 to enable alerting to my custom DS plugin.
Followed the backend-plugin tutorial - [https://grafana.com/tutorials/build-a-data-source-backend-plugin/#1] and succesfully enabled alerting tab.

Tried to make this this method under sample-plugin.go to dynamic instead of using 2 static points given as an example.

Have search enough on how to make this dynamic and being new to GO , can someone help me in making this
1)method dynamic and
2) how to use the rest api of query method in Golang.
3)How specify format as Table so that i receive dataframe as table response when it tries to process in processDataFrames.ts file

Have referred simple-json-datasource as well .

Tried sample code.

func (td *SampleDatasource) query(ctx context.Context, query backend.DataQuery, req *backend.QueryDataRequest) backend.DataResponse {
// Unmarshal the json into our queryModel
var qm queryModel
//var nm neoModel
log.DefaultLogger.Info(“QUERY”, “query”, query)
var neoAttr map[string]*json.RawMessage
err := json.Unmarshal(query.JSON, &neoAttr)
if err != nil {
log.DefaultLogger.Info(“query”, “err–”, err)

log.DefaultLogger.Info("QUERY", "neoAttr", neoAttr)

queryText := neoAttr["queryText"]
log.DefaultLogger.Info("QUERY", "queryText--", queryText)

payload := simplejson.New()
log.DefaultLogger.Info("QUERY", "payload", payload)
payload.SetPath([]string{"range", "to"}, query.TimeRange.To)
payload.SetPath([]string{"range", "from"}, query.TimeRange.From)
log.DefaultLogger.Info("QUERY", "payload", payload)
qs := []interface{}{}
qs = append(qs, queryText)
log.DefaultLogger.Info("QUERY", "qs", qs)
payload.Set("targets", qs)
log.DefaultLogger.Info("QUERY", "payload", payload)
rbody, err := payload.MarshalJSON()
log.DefaultLogger.Info("QUERY", "rbody", rbody)
url := "http://localhost:3000/api/datasources/proxy/2"
log.DefaultLogger.Info("QUERY", "url", url)

queryRequest, err := http.NewRequest(http.MethodPost, url, strings.NewReader(string(rbody)))
queryRequest.Header.Add("Content-Type", "application/json")
if err != nil {
	log.DefaultLogger.Info("QUERY", "err queryRequest", err)
log.DefaultLogger.Info("QUERY", "queryRequest", queryRequest)
queryResponse, err := ctxhttp.Do(ctx, httpClient, queryRequest)
if err != nil {
	log.DefaultLogger.Info("QUERY", "err request", err)

log.DefaultLogger.Info("QUERY", "queryResponse", queryResponse)

response := backend.DataResponse{}

response.Error = json.Unmarshal(query.JSON, &qm)
if response.Error != nil {
	return response

// Log a warning if `Format` is empty.
if qm.Format == "" {
	log.DefaultLogger.Warn("format is empty. defaulting to time series")

// create data frame response
frame := data.NewFrame("response")

// add the time dimension
frame.Fields = append(frame.Fields,
	data.NewField("time", nil, []time.Time{query.TimeRange.From, query.TimeRange.To}),

// add values
frame.Fields = append(frame.Fields,
	data.NewField("values", nil, []int64{10, 20}),

// add the frames to the response
response.Frames = append(response.Frames, frame)

return response