metadataQueryRange returns the best range to query for metadata queries based on the timerange in the ingester.
(queryStart, queryEnd int64, db *userTSDB, queryIngestersWithin time.Duration)
| 3742 | |
| 3743 | // metadataQueryRange returns the best range to query for metadata queries based on the timerange in the ingester. |
| 3744 | func metadataQueryRange(queryStart, queryEnd int64, db *userTSDB, queryIngestersWithin time.Duration) (mint, maxt int64, err error) { |
| 3745 | if queryIngestersWithin > 0 { |
| 3746 | // If the feature for querying metadata from store-gateway is enabled, |
| 3747 | // then we don't want to manipulate the mint and maxt. |
| 3748 | return queryStart, queryEnd, nil |
| 3749 | } |
| 3750 | |
| 3751 | // Ingesters are run with limited retention and we don't support querying the store-gateway for labels yet. |
| 3752 | // This means if someone loads a dashboard that is outside the range of the ingester, and we only return the |
| 3753 | // data for the timerange requested (which will be empty), the dashboards will break. To fix this we should |
| 3754 | // return the "head block" range until we can query the store-gateway. |
| 3755 | |
| 3756 | // Now the question would be what to do when the query is partially in the ingester range. I would err on the side |
| 3757 | // of caution and query the entire db, as I can't think of a good way to query the head + the overlapping range. |
| 3758 | mint, maxt = queryStart, queryEnd |
| 3759 | |
| 3760 | lowestTs, err := db.StartTime() |
| 3761 | if err != nil { |
| 3762 | return mint, maxt, err |
| 3763 | } |
| 3764 | |
| 3765 | // Completely outside. |
| 3766 | if queryEnd < lowestTs { |
| 3767 | mint, maxt = db.Head().MinTime(), db.Head().MaxTime() |
| 3768 | } else if queryStart < lowestTs { |
| 3769 | // Partially inside. |
| 3770 | mint, maxt = 0, math.MaxInt64 |
| 3771 | } |
| 3772 | |
| 3773 | return |
| 3774 | } |
| 3775 | |
| 3776 | func wrappedTSDBIngestErr(ingestErr error, timestamp model.Time, labels []cortexpb.LabelAdapter) error { |
| 3777 | if ingestErr == nil { |
no test coverage detected